Strange behavior of sort on unmapped field


(aldm) #1

Hi,

I'm using elasticsearch script sort and having some problems. I' working on
unmapped field with query:

{"script" : "types.contains(doc['_type'].value) ? doc['popularity'].value :
0", "order" : "desc", "type" : "number", "params" : {"types" : ["type1"]}

So this works fine except one strange issue:
Some documents doesn't have 'popularity' property (it's mapped but it's
missing from document). Some of those documents are shown in result and
some doesn't and query is partially failed but again return results. I
workaround this issue with another condition

doc['popularity'].empty ? 0 : doc['popularity'].value,

but I would still like to know why this strange behavior is happening.

Now I would like to know why all documents with missing 'popularity'
property are not handled same (some are in result set and some of them
missing from result set)?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/23a102cb-d34f-45c6-a1df-f663991ba423%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #2