[英]Best way to define dynamic mapping index fields in elasticsearch
I have some couple of objects which contains dynamic keys.我有一些包含动态键的对象。 How can i define the mappings so that the search query gets optimised.我如何定义映射以便优化搜索查询。
eg I have following nested and object type fields例如,我有以下嵌套和 object 类型字段
"similarities": [
{
"key1": "value1",
"key2": "value2"
},
{
"key3": "value1",
"key4": "value2"
}
]
"entity": {
"version": "SO",
"Non-Commerical": "GGP"
}
For result, i need all documents where entity
contains GGP
no matter what the key is.对于结果,我需要entity
包含GGP
的所有文档,无论密钥是什么。 Can you help in defining the mappings and search query?您能帮忙定义映射和搜索查询吗?
You can use dynamic mapping for entity.*
with copy_to to another field, let's say entity_values
.您可以将entity.*
的动态映射与copy_to一起使用到另一个字段,比如说entity_values
。 Then you just need a match
query against entity_values
which now contains all of the values.然后,您只需要对entity_values
进行match
查询,该查询现在包含所有值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.