2016-05-10 4 views

Antwort

2

Bedenkt man, dass Sie die JSON-Mapping in einer Variablen rawMapping wie dieses:

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

Sie können den Index erstellen die rohe Mapping wie folgt aus:

client.execute { 
    create index "services" source rawMapping 
} 
+0

Sie die 'rawmapping' String brauchen beginnt mit '" mappings ": {...}'. Die API ist jetzt 'createIndex (" Dienste ") Quelle rawMapping' – salvob

Verwandte Themen