2012-04-03 94 views
1

我遇到了一個問題,因爲我有一個用elasticsearch索引的文檔,當我查詢多值字段時,它不返回結果。這裏是我的搜索:查詢多值屬性的ElasticSearch問題

捲曲-X GET 的 「http:// mncoboss13:9200/boss_model_reservations/_search漂亮=真正的」 -d「{ 「查詢」:{ 「MATCH_ALL」:{}} ,「filter」:{「and」:{「day_plan」:[「MO」]}}],「size」:100,「from」:0}'

結果:

{ 「花」:2, 「TIMED_OUT」:假的, 「_shards」:{ 「總」:5, 「成功」:5, 「輝主導」:0}, 「命中」:{ 「總」:0, 「MAX_SCORE」:空, 「點擊」:[]}}

這裏是我索引的文檔的方式(注意day_plan是一個字符串數組)。注意,即使在下面的例子中,它也有一個MO內的day_plan;但是,鑑於上述搜索,不會返回。我的過濾器有問題嗎?

HTTP:// mncoboss13:9200/boss_model_reservations/_search漂亮=真& Q = * &大小= 1

{ 
     "took" : 2, 
     "timed_out" : false, 
     "_shards" : { 
      "total" : 5, 
      "successful" : 5, 
      "failed" : 0 
     }, 
     "hits" : { 
      "total" : 27493, 
      "max_score" : 1.0, 
      "hits" : [ { 
      "_index" : "boss_model_reservations", 
      "_type" : "boss_model_reservation", 
      "_id" : "779588", 
      "_score" : 1.0, "_source" : {"name":"","upccode":"701592001542","publish":true,"reservation_type":"class","time_start":37200.0,"time_end":39000.0,"date_start":"2012-07-19","date_end":"2012-07-30","day_plan":["MO","TU","WE","TH"]} 
      } ] 
     } 
     } 

UPDATE:此索引的類型映射是在這裏:

{ 
    "boss_model_reservations" : { 
    "boss_model_reservation" : { 
     "properties" : { 
     "date_end" : { 
      "type" : "date", 
      "format" : "dateOptionalTime" 
     }, 
     "date_start" : { 
      "type" : "date", 
      "format" : "dateOptionalTime" 
     }, 
     "day_plan" : { 
      "type" : "string" 
     }, 
     "format_id" : { 
      "type" : "long" 
     }, 
     "interest_id" : { 
      "type" : "long" 
     }, 
     "name" : { 
      "type" : "string" 
     }, 
     "option1" : { 
      "type" : "string" 
     }, 
     "option2" : { 
      "type" : "string" 
     }, 
     "option3" : { 
      "type" : "string" 
     }, 
     "product_line_id" : { 
      "type" : "long" 
     }, 
     "product_type" : { 
      "type" : "string" 
     }, 
     "publish" : { 
      "type" : "boolean" 
     }, 
     "reservation_type" : { 
      "type" : "string" 
     }, 
     "resource" : { 
      "type" : "string" 
     }, 
     "resource_type" : { 
      "type" : "string" 
     }, 
     "time_end" : { 
      "type" : "double" 
     }, 
     "time_start" : { 
      "type" : "double" 
     }, 
     "upccode" : { 
      "type" : "string" 
     } 
     } 
    } 
    } 
} 

回答

3

「boss_model_reservation」的類型映射是什麼?術語過濾器假定未分析字段「day_plan」。

+0

我已更新問題以顯示索引映射。它表明它是一種類型:「字符串」 – ejlevin1 2012-04-03 18:16:47

+0

curl -XPUT'http:// localhost:9200/boss_model_reservations/boss_model_reservation/_mapping'-d'{boss'model__reservation':{ 「properties」:{ 「day_plan」 :{ 「類型」: 「串」, 「索引」: 「not_analyzed」} } } }」 – ejain 2012-04-03 18:18:58

+0

映射需要顯示 「day_plan」:{ 「類型」: 「串」, 「索引」: 「not_analyzed」 },那麼術語過濾器起作用。 – ejain 2012-04-03 18:21:11