2017-05-02 8 views
0

Ich lerne ElasticSearch mit der Version 5.1. Ich habe einen Index "mycontent" und einen Typ "simpledocument". Ich bekomme einen Fehler "Illegal_argument_exception no mapping found for field" beim Versuch, die suggest/completion-Funktion auf dem SimpleDocument-Typ zu überprüfen. Die Details sind unten:illegal_argument_exception keine Zuordnung für das Feld in der Suche gefunden

GET _search 
{ 
    "suggest":{ 
    "my-suggestion":{ 
     "prefix":"ap", 
     "completion":{ 
     "field":"suggest" 
     } 
    } 
    } 
} 

Das gibt mir die Antwort:

{ 
    "took": 4, 
    "timed_out": false, 
    "_shards": { 
    "total": 6, 
    "successful": 5, 
    "failed": 1, 
    "failures": [ 
     { 
     "shard": 0, 
     "index": ".kibana", 
     "reason": { 
      "type": "illegal_argument_exception", 
      "reason": "no mapping found for field [suggest]" 
     } 
     } 
    ] 
    }, 
...... 

Die Zuordnung der darin vorschlagen Feld hat:

GET _mapping/simpledocument 

{ 
    "mycontent": { 
    "mappings": { 
     "simpledocument": { 
     "properties": { 
      "description": { 
      "type": "text", 
      "fields": { 
       "keyword": { 
       "type": "keyword", 
       "ignore_above": 256 
       } 
      } 
      }, 
      "id": { 
      "type": "integer" 
      }, 
      "name": { 
      "type": "text", 
      "fields": { 
       "keyword": { 
       "type": "keyword", 
       "ignore_above": 256 
       } 
      } 
      }, 
      "path": { 
      "type": "keyword" 
      }, 
      "suggest": { 
      "type": "completion", 
      "analyzer": "simple", 
      "preserve_separators": true, 
      "preserve_position_increments": true, 
      "max_input_length": 50 
      }, 
      "tags": { 
      "type": "keyword" 
      } 
     } 
     } 
    } 
    } 
} 

Hier ist ein Beispieldokument:

GET mycontent/simpledocument/7 
{ 
    "_index": "mycontent", 
    "_type": "simpledocument", 
    "_id": "7", 
    "_version": 1, 
    "found": true, 
    "_source": { 
    "name": "Suggested Document", 
    "description": "this document does not contain a lot of content. Mainly used to test the suggest feature.", 
    "tags": [ 
     "suggest", 
     "document" 
    ], 
    "suggest": [ 
     "and", 
     "design", 
     "api" 
    ] 
    } 
} 

Kann jemand pl Leichtigkeit helfen Sie mir, meinen Fehler zu finden? Warum heißt es "no mapping found" wenn das Mapping da ist?

Antwort

2

GET _search alle Index suchen als Fehler, es sagt der Index .kibana nicht das suggest Feld hat, wie Ihr GET _mapping/simpledocument, die vorschlagen Feld nur in simpedocumentIndextyp existieren sollten.

so vielleicht müssen Sie es tun:

GET mycontent/simpledocument/_search 
{ 
    "suggest":{ 
    "my-suggestion":{ 
     "prefix":"ap", 
     "completion":{ 
     "field":"suggest" 
     } 
    } 
    } 
} 
+0

Ah .. danke! – sammy

Verwandte Themen