2015-04-23 61 views
0

我一直在努力解決一個簡單的語法問題,試圖做一個基本的ES映射工作。這是1.1.1版ElasticSearch映射「不能正常工作」v1.1.1

我有一個要點,以便能夠從頭開始創建一切:

https://gist.github.com/jrmadsen67/1fc5e296e26e7a5edae0

映射查詢:

PUT /movies/movie/_mapping 
{ 
    "movie": { 
     "properties": { 
     "director": { 
      "type": "multi_field", 
      "fields": { 
       "director": {"type": "string"}, 
       "original": {"type" : "string", "index" : "not_analyzed"} 
      } 
     } 
     } 
    } 
} 

我跑:

curl localhost:9200/movies/movie/_mapping?pretty=true 

確認映射實際上存在

查詢:

POST /movies/movie/_search 
{ 
    "query": { 
     "constant_score": { 
      "filter": { 
       "term": { "director.original": "Francis Ford Coppola" } 
      } 
     } 
    } 
} 

沒有得到任何命中。 {「導演」:「弗朗西斯」}按預期工作。

非常感謝另一組眼睛,可以告訴我這有什麼問題!

+1

我想你的數據集和查詢。它工作得很好。它確實返回了2個結果。不同之處在於我使用的是elasticsearch版本1.5。但我覺得版本並不重要 –

+0

謝謝你的幫助!我有一種感覺,這是我的設置本地的東西 - 沒有別的意義 – jmadsen

+0

記錄您的查詢,並檢查它的任何不尋常的東西。您可以通過將config中的slow.log參數設置爲0來完成此操作,以便所有查詢的記錄速度都很慢。 –

回答

0

匹配你的文件,其目前的映射是:

{ 
    "movie" : { 
     "properties" : { 
      "director" : { 
       "type" : "string" 
      }, 
      "genres" : { 
       "type" : "string" 
      }, 
      "title" : { 
       "type" : "string" 
      }, 
      "year" : { 
       "type" : "long" 
      } 
     } 
    } 
} 

要匹配你的映射和查詢,文件應該看起來像:

{ 
    "director": { 
     "director": "Francis Ford Coppola", 
     "original": "xxxxxx" 
    } 
}