Created
October 3, 2012 20:30
-
-
Save phillro/3829655 to your computer and use it in GitHub Desktop.
fuzzy_versus_bool_custom_score_with_geo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Works | |
{ query: | |
{ custom_score: | |
{ query: {"match_all":{}}, | |
params: {lat:43,lon:73}, | |
script: '(1-(doc["geo"].distanceInKm(lat,lon)/maxDistance))*distanceWeight+scoreWeight*_score' } }, | |
script_fields: { distance: { params:{lat:43,lon:73}, script: 'doc["geo"].distanceInKm(lat,lon)' } }, | |
fields: | |
[ '_id', | |
'name', | |
'geo' ], | |
from: 0, | |
size: 10 } | |
//Doesn't work | |
{ query: | |
{ custom_score: | |
{ | |
query: {"fuzzy":{ | |
"name":{ | |
"value":"pizza", | |
"min_similarity":.8, | |
"max_expansions":25 | |
} | |
} | |
}, | |
params: {lat:43,lon:73}, | |
script: '(1-(doc["geo"].distanceInKm(lat,lon)/maxDistance))*distanceWeight+scoreWeight*_score' } }, | |
script_fields: { distance: { params:{lat:43,lon:73}, script: 'doc["geo"].distanceInKm(lat,lon)' } }, | |
fields: | |
[ '_id', | |
'name', | |
'geo' ], | |
from: 0, | |
size: 10 } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment