gpt4 book ai didi

elasticsearch - 我如何使用Lucene查询语法在Elastic Search中进行嵌套字段查询

转载 作者:行者123 更新时间:2023-12-03 02:12:57 24 4
gpt4 key购买 nike

这是简单的用例,
我有一个将Lucene查询发送到我的 Elasticsearch 的系统。我有一个映射

{
"mappings": {
"properties": {
"grocery_name":{
"type": "text"
},
"items": {
"type": "nested",
"properties": {
"name": {
"type": "text"
},
"stock": {
"type": "integer"
},
"category": {
"type": "text"
}
}
}
}
}
}

数据看起来像
{
"grocery_name": "Elastic Eats",
"items": [
{
"name": "banana",
"stock": "12",
"category": "fruit"
},
{
"name": "peach",
"stock": "10",
"category": "fruit"
},
{
"name": "carrot",
"stock": "9",
"category": "vegetable"
},
{
"name": "broccoli",
"stock": "5",
"category": "vegetable"
}
]
}
我如何查询以获取所有项目名称为 香蕉股票> 10 的所有项目,在KQL中我可以编写类似 items:{ name:banana and stock > 10 }的代码

最佳答案

Lucene表达式语言不支持查询嵌套文档。因此,KQL语言填补了这一空白。
目前,这是通过Kibana搜索栏查询嵌套文档的唯一方法。

关于elasticsearch - 我如何使用Lucene查询语法在Elastic Search中进行嵌套字段查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64222222/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com