2016-01-03 18 views
6

Problema: Ho creato la mappatura e il suo bel lavoro in elasticsearch 1.7.1 ma dopo l'aggiornamento a 2.1.1 che mi darà eccezionemapper_parsing_exception in new elasticsearch 2.1.1 versione

ECCEZIONE

response: '{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason" 
:"analyzer on field [_all] must be set when search_analyzer is set"}],"type":"ma 
pper_parsing_exception","reason":"Failed to parse mapping [movie]: analyzer on f 
ield [_all] must be set when search_analyzer is set","caused_by":{"type":"mapper 
_parsing_exception","reason":"analyzer on field [_all] must be set when search_a 
nalyzer is set"}},"status":400}', 
    toString: [Function], 
    toJSON: [Function] } 

{ 
    "settings": { 
     "number_of_shards": 1, 
     "number_of_replicas": 0, 
     "analysis": { 
      "filter": { 
       "nGram_filter": { 
        "type": "nGram", 
        "min_gram": 2, 
        "max_gram": 20, 
        "token_chars": [ 
         "letter", 
         "digit", 
         "punctuation", 
         "symbol" 
        ] 
       } 
      }, 
      "analyzer": { 
       "nGram_analyzer": { 
        "type": "custom", 
        "tokenizer": "whitespace", 
        "filter": [ 
         "lowercase", 
         "asciifolding", 
         "nGram_filter" 
        ] 
       }, 
       "whitespace_analyzer": { 
        "type": "custom", 
        "tokenizer": "whitespace", 
        "filter": [ 
         "lowercase", 
         "asciifolding" 
        ] 
       } 
      } 
     } 
    }, 
    "mappings": { 
     "movie": { 
      "_all": { 
       "index_analyzer": "nGram_analyzer", 
       "search_analyzer": "whitespace_analyzer" 
      }, 
      "properties": { 
       "movieName": { 
        "type": "string", 
        "index": "not_analyzed" 
       }, 
       "movieYear": { 
        "type": "double" 
       }, 
       "imageUrl": { 
        "type": "string" 
       }, 
       "genre": { 
        "type": "string" 
       }, 
       "director": { 
        "type": "string" 
       }, 
       "producer": { 
        "type": "string" 
       }, 
       "cast": { 
        "type": "String" 
       }, 
       "writer": { 
        "type": "string" 
       }, 
       "synopsis": { 
        "type": "string" 
       }, 
       "rating": { 
        "type": "double" 
       }, 
       "price": { 
        "type": "double" 
       }, 
       "format": { 
        "type": "string" 
       }, 
       "offer": { 
        "type": "double" 
       }, 
       "offerString": { 
        "type": "string" 
       }, 
       "language": { 
        "type": "string" 
       } 
      } 
     } 
    } 
} 

risposta

11

L'errore è abbastanza chiaro se mi chiedi, è necessario specificare analyzer per _all nella mappatura del film. L'impostazione index_analyzer è stata rimossa in Elasticsearch 2.0.

 "_all": { 
      "analyzer": "nGram_analyzer", 
      "search_analyzer": "whitespace_analyzer" 
     }, 
+0

quindi cos'è index_analyzer? puoi dirmi per favore –

+1

In Elasticsearch prima del 2.0 puoi impostare 'index_analyzer', 'search_analyzer' o semplicemente' analizzatore'. L'ultimo era una scorciatoia per impostare sia 'index_analyzer' che 'search_analyzer' sullo stesso valore. In Elasticsearch 2.0 sono stati modificati in modo che 'index_analyzer' ora sia solo' analizzatore' e se non si imposta un 'search_analyzer' separato, il valore di' analyzer' viene utilizzato anche per questo. –