I am trying to wire up a search that gives documents near a location a higher ranking. Pretty simple but in our case some of the documents won't always have a location associated with them. When using a function_score query the documents with no location always get scored higher than the ones with a location, even if I search with the exact coordinates. Here is an example:
Documents: PUT /test/colors/1 { "name":"red" } PUT /test/colors/2 { "name":"red", "location":{"lat":47,"lon":-122} } Mapping: "mappings" : { "colors" : { "properties" : { "location" : { "lat_lon" : true, "type" : "geo_point", "geohash" : true }, "name" : { "type" : "string" } } } } Query: { "query":{ "function_score":{ "query":{ "multi_match":{ "type":"phrase", "query":"red", "fields":["name"], "tie_breaker":0.3 } }, "functions":[ { "gauss": { "location": { "origin": "47,-122", "scale": "10mi" } } } ] } } } Results: { "took": 3, "timed_out": false, "_shards": { "total": 2, "successful": 2, "failed": 0 }, "hits": { "total": 2, "max_score": 0.30685282, "hits": [ { "_index": "test", "_type": "colors", "_id": "1", "_score": 0.30685282, "_source": { "name": "red" } }, { "_index": "test", "_type": "colors", "_id": "2", "_score": 0.30685282, "_source": { "name": "red", "location": { "lat": 47, "lon": -122 } } } ] } } Is there any way to factor proximity in for some results and not others? -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/59f8e2e1-856a-432b-a034-b71e31110ae9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.