views:

103

answers:

1

I want to filter a property within a range, but items that does not have the property should come last in the result. My solution was to set it to -1 if the property was not set.

+(property:[10000000001 TO 10000000019] property:"-1"^0.5)

This doesn't work, since every document with property:-1 get a very high score, for some reason. Is there a way to reliably control the sorting here?

Boosting the range instead would mean I must boost every other term, which I'd rather not do.

A: 

The property with value -1 is boosted, so removing it would give you better results.

Furthermore if a property is missing, just keep it missing. Don't set it to -1.

You can sort the result with sort=property desc in the query or sort the property while indexing with sortMissingLast=true

Jem
Thanks for the answer! What would the query look like if I don't set missing properties to `-1`? Would `+(property:[10000000001 TO 10000000019])` really return documents without `property` if I use `sortMissingLast`?
Znarkus