如何使用列表为嵌套数据结构创建索引?将有 otherUserID 的列表,我不知道如何使用 elasticsearch 6.5 为它们编制索引。
UserID -> OtherUserID-> name:"text" , count : "long"
您可以使用嵌套数据类型来创建这样的字段和对象索引列表。请参考下面的示例并根据您的需要进行修改:
映射:
PUT testindex
{
"mappings": {
"_doc": {
"properties": {
"nestedField": {
"type": "nested",
"properties": {
"field1": {
"type": "text",
"fields": {
"keywords": {
"type": "keyword"
}
}
},
"field2": {
"type": "integer"
}
}
}
}
}
}
}
添加文档:
对于列表中的单个项目:
PUT testindex/_doc/1
{
"nestedField": [
{
"field1": "Some text",
"field2": 10
}
]
}
对于列表中的多个项目:
PUT testindex/_doc/2
{
"nestedField": [
{
"field1": "Some other text",
"field2": 11
},
{
"field1": "random value",
"field2": 15
}
]
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句