3

( https://www.elastic.co/guide/en/elasticsearch/reference/current/suggester-context.html )のように、いくつかのコンテキスト補完サジェスター マッピングを持つインデックスを作成する必要があります。https://github.com/sksamuel/elastic4s/issues/452でわかるように、これは DSL でサポートされていないようです。

そのため、生の JSON 文字列 (生のクエリと同様) からインデックスを作成すると便利です。これを達成することは可能ですか?

4

1 に答える 1

3

Considering that you have the JSON mapping in a variable rawMapping like this:

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"
                              }
                      }
                  }
              }
              }
          }"""

You can create the index using the raw mapping like this:

client.execute {
    create index "services" source rawMapping
}
于 2016-06-24T16:52:48.717 に答える