我需要创建一个索引,其中包含一些上下文完成建议器映射,如(https://www.elastic.co/guide/en/elasticsearch/reference/current/suggester-context.html)。正如我在https://github.com/sksamuel/elastic4s/issues/452中看到的,这似乎不受 DSL 支持。
因此,最好从原始 JSON 字符串创建索引(类似于原始查询)。有可能实现这一目标吗?
我需要创建一个索引,其中包含一些上下文完成建议器映射,如(https://www.elastic.co/guide/en/elasticsearch/reference/current/suggester-context.html)。正如我在https://github.com/sksamuel/elastic4s/issues/452中看到的,这似乎不受 DSL 支持。
因此,最好从原始 JSON 字符串创建索引(类似于原始查询)。有可能实现这一目标吗?
考虑到您在这样的变量中有 JSON 映射rawMapping
:
val rawMapping =
"""{
"service": {
"properties": {
"name": {
"type" : "string"
},
"tag": {
"type" : "string"
},
"suggest_field": {
"type": "completion",
"context": {
"color": {
"type": "category",
"path": "color_field",
"default": ["red", "green", "blue"]
},
"location": {
"type": "geo",
"precision": "5m",
"neighbors": true,
"default": "u33"
}
}
}
}
}
}"""
您可以像这样使用原始映射创建索引:
client.execute {
create index "services" source rawMapping
}