2017-02-09 86 views
0

這裏是我的索引設置JSON創建索引,當我測試 http://localhost:9200/myIndex/_analyze?text=「測試儀」 &儀= nGram_analyzer 我得到了以下異常。Elasticsearch無法找到分析儀,但它沒有任何錯誤

{ 
    "error": { 
    "root_cause": [ 
     { 
     "type": "remote_transport_exception", 
     "reason": "[Infectia][127.0.0.1:9300][indices:admin/analyze[s]]" 
     } 
    ], 
    "type": "illegal_argument_exception", 
    "reason": "failed to find analyzer [nGram_analyzer]" 
    }, 
    "status": 400 
} 

索引設置

{ 
     "myIndex": { 
     "mappings": { 
      "practices": { 
      "properties": { 
       "practiceCity": { 
       "type": "string", 
       "index":"analyzed", 
       "analyzer": "nGram_analyzer" 
       }, 
       "practiceId": { 
       "type": "long", 
       "index":"not_analyzed" 
       }, 
       "practiceName": { 
       "type": "string", 
       "boost": 10, 
       "index":"analyzed", 
       "analyzer": "nGram_analyzer" 
       }, 
       "practicePhone": { 
       "type": "long", 
       "boost": 10, 
       "index":"analyzed", 
       "analyzer": "nGram_analyzer" 
       }, 
       "practiceService": { 
       "type": "string", 
       "boost": 5, 
       "index":"not_analyzed" 
       } 
      } 
      }, 
      "users": { 
      "_all": { 
       "analyzer": "nGram_analyzer" 
      }, 
      "properties": { 
       "userCityId": { 
       "type": "long", 
       "index":"not_analyzed", 
       "analyzer": "nGram_analyzer" 
       }, 
       "userCityName": { 
       "type": "string", 
       "index":"not_analyzed" 
       }, 
       "userEmail": { 
       "type": "string", 
       "index":"analyzed", 
       "analyzer": "nGram_analyzer" 
       }, 
       "userFirstName": { 
       "type": "string", 
       "boost": 10, 
       "index":"analyzed", 
       "analyzer": "nGram_analyzer" 
       }, 
       "userId": { 
       "type": "long" 
       }, 
       "userLastName": { 
       "type": "string", 
       "boost": 10, 
       "index":"analyzed", 
       "analyzer": "nGram_analyzer" 
       }, 
       "userMobile": { 
       "type": "string", 
       "index":"analyzed", 
       "analyzer": "nGram_analyzer" 
       }, 
       "userSpecialization": { 
       "type": "string", 
       "boost": 5, 
       "index":"not_analyzed" 
       } 
      } 
      } 
     }, 
     "settings": { 
      "index": { 
      "analysis": { 
      "analyzer": { 
      "nGram_analyzer": { 
       "type":  "custom", 
       "tokenizer": "standard", 
        "filter": [ 
        "nGram_filter" 
        ] 
       } 
       }, 
       "filter": { 
       "nGram_filter": { 
        "max_gram": "20", 
        "type": "edgeNGram", 
        "min_gram": "3", 
        "token_chars": [ 
        "letter", 
        "digit", 
        "punctuation", 
        "symbol" 
        ] 
       } 
       } 
      }, 
      "number_of_replicas": "1", 
      "number_of_shards": "5" 
      } 
     } 
     } 
    } 

我工作的自動完成功能,是我的指標看起來不錯? 有沒有提高性能的建議?

回答

1

您需要更改settings部分是這樣的:(即analysis直接進入settings不得以index

PUT myindex 
{ 
    "mappings": { 
    "practices": { 
     "properties": { 
     "practiceCity": { 
      "type": "string", 
      "index": "analyzed", 
      "analyzer": "nGram_analyzer" 
     }, 
     "practiceId": { 
      "type": "long", 
      "index": "not_analyzed" 
     }, 
     "practiceName": { 
      "type": "string", 
      "boost": 10, 
      "index": "analyzed", 
      "analyzer": "nGram_analyzer" 
     }, 
     "practicePhone": { 
      "type": "long", 
      "boost": 10 
     }, 
     "practiceService": { 
      "type": "string", 
      "boost": 5, 
      "index": "not_analyzed" 
     } 
     } 
    }, 
    "users": { 
     "properties": { 
     "userCityId": { 
      "type": "long" 
     }, 
     "userCityName": { 
      "type": "string", 
      "index": "not_analyzed" 
     }, 
     "userEmail": { 
      "type": "string", 
      "index": "analyzed", 
      "analyzer": "nGram_analyzer" 
     }, 
     "userFirstName": { 
      "type": "string", 
      "boost": 10, 
      "index": "analyzed", 
      "analyzer": "nGram_analyzer" 
     }, 
     "userId": { 
      "type": "long" 
     }, 
     "userLastName": { 
      "type": "string", 
      "boost": 10, 
      "index": "analyzed", 
      "analyzer": "nGram_analyzer" 
     }, 
     "userMobile": { 
      "type": "string", 
      "index": "analyzed", 
      "analyzer": "nGram_analyzer" 
     }, 
     "userSpecialization": { 
      "type": "string", 
      "boost": 5, 
      "index": "not_analyzed" 
     } 
     } 
    } 
    }, 
    "settings": { 
    "index": { 
     "number_of_replicas": "1", 
     "number_of_shards": "5" 
    }, 
    "analysis": { 
     "analyzer": { 
     "nGram_analyzer": { 
      "type": "custom", 
      "tokenizer": "standard", 
      "filter": [ 
      "nGram_filter" 
      ] 
     } 
     }, 
     "filter": { 
     "nGram_filter": { 
      "max_gram": "20", 
      "type": "edgeNGram", 
      "min_gram": "3", 
      "token_chars": [ 
      "letter", 
      "digit", 
      "punctuation", 
      "symbol" 
      ] 
     } 
     } 
    } 
    } 
} 
+0

抱歉這樣說......不工作的Val,同樣的錯誤響應。 我剛剛複製了您的固定索引設置節點。 –

+0

我已解決問題並更新了我的答案,請再試一次。 – Val

+0

沒有先生,它尚未修復,獲得相同的錯誤響應。 –

相關問題