ElasticSearch问题,查询多值属性

时间:2012-04-03 17:57:27

标签: lucene elasticsearch

我遇到了一个问题,因为我有一个用elasticsearch索引的文档,当我查询多值字段时,它没有返回任何结果。这是我的搜索:

  

卷曲-X GET   “HTTP:// mncoboss13:9200 / boss_model_reservations / _search漂亮=真”   -d'{“query”:{“match_all”:{}},“过滤器”:{“和”:[{“terms”:{“day_plan”:[“MO”]}}]},“size” :100 “从”:0}“

结果:

  

{“take”:2,“timed_out”:false,“_ shards”:{       “总数”:5,       “成功”:5,       “失败”:0},“点击”:{       “总数”:0,       “max_score”:null,       “点击”:[]}}

这是我索引文档的方式(注意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"]}
          } ]
        }
      }

更新:此索引的类型映射位于:

{
  "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"
        }
      }
    }
  }
}

1 个答案:

答案 0 :(得分:3)

“boss_model_reservation”的类型映射是什么?术语过滤器假定未分析字段“day_plan”。