2012-08-17 41 views
1

https://gist.github.com/3442562當我重新啓動Elastic Search時,爲什麼我的分析儀消失?

完全依據我的分析:

"analyzer" : { 
      "lowercase_keyword" : { 
       "type" : "custom", 
       "tokenizer" : "keyword", 
       "filter" : ["lowercase", "trim"] 
      } 
     } 

是在映射引用:

"location_countries" : { 
       "properties" : { 
        "country" : { 
         "type" : "string", 
         "analyzer" : "lowercase_keyword" 
        } 
       } 
      } 

當我使用「國家」字段中的過濾器或該字段被(正確)視爲關鍵字。

curl -XGET 'localhost:9200/clinical_trials/_search?pretty=true' -d ' 
{ 
    "query" : { 
     "term" : { "brief_title" : "dermatitis" } 
    }, 
    "filter" : { 
     "term" : { "country" : "united states" } 
    }, 
    "facets" : { 
     "tag" : { 
      "terms" : { "field" : "country" } 
     } 
    } 
} 
' 

方面的結果:直到機器被重新啓動或彈性搜索服務被重新啓動

"facets" : { 
    "tag" : { 
     "_type" : "terms", 
     "missing" : 0, 
     "total" : 1, 
     "other" : 0, 
     "terms" : [ { 
     "term" : "united states", 
     "count" : 1 
     } ] 
    } 

,一切工作正常。重啓後,我的所有過濾器都停止工作,就好像分析儀不存在一樣。

在對同一個數據結果同樣的查詢:

"facets" : { 
    "tag" : { 
     "_type" : "terms", 
     "missing" : 0, 
     "total" : 2, 
     "other" : 0, 
     "terms" : [ { 
     "term" : "united", 
     "count" : 1 
     }, { 
     "term" : "states", 
     "count" : 1 
     } ] 
    } 

如果我詢問我的索引的_settings/_mappings,分析和映射仍然正確定義,但分析似乎沒有任何效果。

我在做什麼錯?

在此先感謝!

+0

A刪除了所有對pyes的引用,因爲我能夠使用curl重新創建我的問題。 – 2012-08-24 17:09:41

回答

0

country字段出現在多個嵌套文檔中,但我只設置了其中一個字段的映射。重新啓動後,elasticsearch以不同的順序加載字段,將過濾器/構面應用於錯誤的字段。

完全限定構面和過濾器字段名稱可修復我的問題。

curl -XGET 'localhost:9200/clinical_trials/_search?pretty=true' -d ' 
{ 
    "query" : { 
     "term" : { "brief_title" : "dermatitis" } 
    }, 
    "filter" : { 
     "term" : { "location_countries.country" : "united states" } 
    }, 
    "facets" : { 
     "tag" : { 
      "terms" : { "field" : "location_countries.country" } 
     } 
    } 
} 
' 

感謝克林特對elasticsearch mailing list的所有幫助。

相關問題