I am trying to use elasticsearch with script_field to return distance in
miles. The distance works but when I use script_field, all the data is lost
that would have been returned if I didn't use script_field. So here is an
example. If I run:
{
"script_fields": {
"distance": {
"script": "doc['lat_lon'].distanceInKm(0,50.3)"
}
},
"query": {
"match_all": {}
}
}
The returned data is
{
took: 1,
timed_out: false,
_shards: {
total: 5,
successful: 5,
failed: 0
},
hits: {
total: 1,
max_score: 1,
hits: [
{
_index: tilofy_test_channels,
_type: channel,
_id: 1,
_score: 1,
fields: {
distance: 19629.025705718916
}
}
]
}
}
However, if I remove script_fields like the following:
{
"query": {
"match_all": {}
}
}
Then I get the correct data which is
{
took: 0,
timed_out: false,
_shards: {
total: 5,
successful: 5,
failed: 0,
}
hits: {
total: 1,
max_score: 1,
hits: [
{
_index: "tilofy_test_channels",
_type: "channel",
_id: 1,
_score: 1,
_source: {
created_at: "2013-04-23T15:50:54Z",
description: "Odit nam vitae facere velit eum
similique. Voluptatem sed voluptas necessitatibus architecto molestiae
voluptates possimus. Quo necessitatibus doloribus aut. Omnis nam non
ratione. Nihil harum esse eaque sunt error consequuntur quia quasi."
id: 1,
image_file_name: null,
latitude: 37.3320132,
longitude: -122.0289113,
name: "Repellat inventore architecto et similique quo
in.",
lat_lon: {
lat: 37.3320132,
lon: -122.0289113
}
}
}
]
}
}
What am I doing wrong? I don't think this behavior make sense to me. Has
anybody else ran to this problem?
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.