That is, I'm trying to sort the documents by the "magnitude" field. If the
field is null then I want those values pushed to the bottom of the result
set. Here's the field definition:
I'm finding that the sort applies a value of "0.0" to all records where the
magnitude field is null. Here's an example of one of the results in the set:
As you can see, there is no "magnitude" field on this record. I would
expect that the script I am using will detect this as a null field and
assign it a score of 2147483647. Is there something wrong with my script?
Any hints will be appreciated. Thanks.
I never did figure out why my null long fields are coming back with a value
of 0.0 but I worked around the issue by changing my script to do the
following:
Would an alternative be to use sort missing last? If you take a look at Elasticsearch Platform — Find real-time answers at scale | Elastic under
Missing Values you can control how numeric fields with missing values are
handled, by either pushing them to first or last, or assigning them a
default value.
On Tuesday, September 18, 2012 5:26:19 AM UTC+12, Kamil wrote:
I never did figure out why my null long fields are coming back with a
value of 0.0 but I worked around the issue by changing my script to do the
following:
I never did figure out why my null long fields are coming back with a value of 0.0 but I worked around the issue by changing my script to do the following:
Thanks Chris and Shay. I tried both solutions and found that "field.empty"
does suit my use case, but that there is a negligible difference in
performance compared to "field.values.length == 0". However, I found that
using "missing": "_last" vastly outperforms the script solution. Here are
the timing results from 10 runs of each solution:
field.values.length:
median: 0.0295s
mean: 0.0280s
stdev: 0.0029s
field.empty:
median: 0.0300s
mean: 0.0300s
stdev: 0.0067s
"missing": "_last":
0.0110s
0.0110s
0.0007s
Thanks.
Kamil
On Tuesday, September 18, 2012 3:16:37 AM UTC-7, kimchy wrote:
Another option that would be slightly more performant is to use
field.empty ? …
On Sep 17, 2012, at 7:26 PM, Kamil <kamil...@gmail.com <javascript:>>
wrote:
I never did figure out why my null long fields are coming back with a
value of 0.0 but I worked around the issue by changing my script to do the
following:
Thanks Chris and Shay. I tried both solutions and found that "field.empty"
does suit my use case, but that there is a negligible difference in
performance compared to "field.values.length == 0". However, I found that
using "missing": "_last" vastly outperforms the script solution. Here are
the timing results from 10 runs of each solution:
field.values.length:
median: 0.0295s
mean: 0.0280s
stdev: 0.0029s
field.empty:
median: 0.0300s
mean: 0.0300s
stdev: 0.0067s
"missing": "_last":
median: 0.0110s
mean: 0.0110s
stdev: 0.0007s
Thanks.
Kamil
On Tuesday, September 18, 2012 3:16:37 AM UTC-7, kimchy wrote:
Another option that would be slightly more performant is to use
field.empty ? …
On Sep 17, 2012, at 7:26 PM, Kamil <kamil...@gmail.com <javascript:>>
wrote:
I never did figure out why my null long fields are coming back with a
value of 0.0 but I worked around the issue by changing my script to do the
following:
This is a "node" level configuration, you set it in the elasticsearch.yml file under config. It will mean that if one doesn't specify a lang for the script, the default lang configured will be used.
On Sep 18, 2012, at 6:16 PM, Kyle Lahnakoski kyle@arcavia.com wrote:
I tried
var query : {
"script" : { default_lang" : "lang-javascipt"},
"query" : {
...
but that does not work. May someone give me an example of a es query that uses javascript?
PS. I hope to use javascript in a facet to loop through children of a document to find the one value to groupby on.
Thank you, but I have no access to the the *.yml files.
My question now regarding the "lang" tag.
Thanks again.
On 9/18/2012 3:53 PM, Shay Banon wrote:
This is a "node" level configuration, you set it in the
elasticsearch.yml file under config. It will mean that if one doesn't
specify a lang for the script, the default lang configured will be used.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.