该示例摘自Elasticsearch引用:https://www.elastic.co/guide/en/elasticsearch/reference/5.3/nested.html
我的索引与此类似。唯一的区别是user.first和user.last是关键字类型,因此我可以对它们使用过滤器。
PUT my_index
{
"mappings": {
"my_type": {
"properties": {
"user": {
"type": "nested"
}
}
}
}
}
PUT my_index/my_type/1
{
"group" : "fans",
"user" : [
{
"first" : "John",
"last" : "Smith"
},
{
"first" : "Alice",
"last" : "White"
}
]
}
在两种情况下,我应该使用什么查询来获取与上述数组匹配的文档(恰好是两项,一项是John Smith,一项是Alice White):
最佳答案
搜索后,获得Order的最佳方法无关紧要:对Count字段建立索引。
另请:Elasticsearch Equal Exactly
原因是:
In Elasticsearch, there is no dedicated array type. Any field can contain zero or more values by default, however, all values in the array must be of the same datatype.
关于elasticsearch - Elasticsearch:匹配嵌套对象的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46135508/