Skip to content

Instantly share code, notes, and snippets.

@phillro
Created October 3, 2012 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phillro/3829655 to your computer and use it in GitHub Desktop.
Save phillro/3829655 to your computer and use it in GitHub Desktop.
fuzzy_versus_bool_custom_score_with_geo
//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