如何在嵌套的geo_point字段上使用function_score

时间:2016-10-12 06:03:08

标签: json elasticsearch

我一直在尝试在嵌套function_score上使用geo_type,但Elasticsearch始终返回_score = 1的文档。

我的映射

{
   "myindex": {
      "mappings": {
         "offers": {
            "properties": {
               "country_id": {
                  "type": "long"
               },
               "created_at": {
                  "type": "date",
                  "format": "yyyy-MM-dd HH:mm:ss"
               },               
               "locations": {
                  "type": "nested",
                  "properties": {
                     "city": {
                        "type": "string",
                        "store": true,
                        "fields": {
                           "city_original": {
                              "type": "string",
                              "analyzer": "keyword_analyzer"
                           }
                        }
                     },
                     "coordinates": {
                        "type": "geo_point"
                     }
                  }
               }               
            }
         }
      }
   }
}

问题是某些文档可能有空坐标。我的问题:

GET /myindex/offers/_search?explain
{
   "query": {
      "nested": {
         "path": "locations",
         "query": {
            "function_score": {
               "functions": [
                  {
                     "filter": {
                        "exists": {
                           "field": "locations.coordinates"
                        }
                     },
                     "gauss": {
                        "locations.coordinates": {
                           "origin": {
                              "lat": 49.1,
                              "lon": 17.03333
                           },
                           "scale": "10km",
                           "offset": "20km"
                        }                        
                     }
                  }
               ]
            }
         }
      }
   }
}

正如我所说,Elasticsearch返回_score = 1的文档和解释:根据子级doc范围从21714到21714的分数

我做错了什么?我的Elastisearch版本是1.7。

0 个答案:

没有答案