elasticsearch geo search with multiple must

时间:2017-05-31 09:23:44

标签: php json curl elasticsearch match

我正在使用带有bool / must / filter的elasticsearch,并使用geo_distance过滤器进行过滤。以下是一些示例查询:

示例1:

curl -XPOST 'localhost:9200/indexname/_search?pretty' -H 'Content-Type: application/json' -d'
{
  "query": {
    "bool" : {
      "must": {
        "term": { "name": "cafe" }
      },        
      "filter": {
        "geo_distance" : {
          "distance" : "20km",
          "pin.coordinates" : {
            "lat" : 13.9291040000,
            "lon" : -70.8269250000
          }
        }
      } 
    }
  }
}

对于上述查询,我​​至少得到1个或更多结果。

示例2:

如果我使用should以及上述查询,则不显示任何匹配/结果

curl -XPOST 'localhost:9200/indexname/_search?pretty' -H 'Content-Type: application/json' -d'
{
  "query": {
    "bool" : {
      "must": {
        "term": { "name": "cafe" }
      },        
      "filter": {
        "geo_distance" : {
          "distance" : "20km",
          "pin.coordinates" : {
            "lat" : 13.9291040000,
            "lon" : -70.8269250000
          }
        }
      },
      "should" : [
        { "term" : { "category_ol" : "cafe" } },
        { "term" : { "name_en" : "cafe" } }
      ],
      "minimum_should_match" : 1,
      "boost" : 1.0   
    }
  }
}

有任何解决方案吗?

TIA

0 个答案:

没有答案