我想定义一个包含嵌套类型数组的索引。但是,无论何时插入文档,我都无法获得嵌套查询的任何结果。
我定义了以下映射:
curl -XPUT http://localhost:9200/test/product/_mapping -d '{
"product": {
"properties": {
"properties": {
"type": "nested"
}
}
}
}'
但是当我添加一个项目时:
curl -XPUT http://localhost:9200/test/product/1432008 -d '{
"properties": [
{
"data_type": 0,
"id": 19,
"name": "Vendor",
"value": "TEST TEST",
"value_id": 16577846
}
]
}'
我得到以下内容:
{
"test": {
"product": {
"properties": {
"properties": {
"type": "nested",
"properties": {
"data_type": {
"type": "long"
},
"id": {
"type": "long"
},
"name": {
"type": "string"
},
"value": {
"type": "string"
},
"value_id": {
"type": "long"
}
}
}
}
}
}
}
实际上看起来是正确的。但是我得到0次点击:
curl -XGET http://localhost:9200/test/product/_search -d '
{
"query": {
"filtered": {
"query": {"match_all": {}},
"filter": {
"nested": {
"path": "properties",
"query":{
"filtered": {
"query": { "match_all": {}},
"filter": {
"and": [
{"term": {"properties.name": "vendor"}},
{"term": {"properties.value": "test test"}}
]
}
}
}
}
}
}
}
}'
任何人都知道我做错了什么?
答案 0 :(得分:0)
试试这个,
curl -XGET http://localhost:9200/test/product/_search -d '
{
"query": {
"filtered": {
"query": {"match_all": {}},
"filter": {
"nested": {
"path": "properties",
"query":{
"filtered": {
"query": { "match_all": {}},
"filter": {
"and": [
{"term": {"name": "Vendor"}},
{"term": {"value": "TEST"}}
]
}
}
}
}
}
}
}
}'
答案 1 :(得分:0)
我意识到这里发生了什么。在我上面的例子中,我稍微改了一下以隐藏业务细节。我忽略了术语过滤器的值为“测试测试”中的空格。空间得到了。我。谢谢你的帮助。