On 4/17/2019 11:49 PM, John Davis wrote:
I did a few tests with our instance solr-7.4.0 and field:* vs field:[* TO *] doesn't seem materially different compared to has_field:1. If no one knows why Lucene optimizes one but not another, it's not clear whether it even optimizes one to be sure.
Queries using a boolean field will be even faster than the all-inclusive range query ... but they require work at index time to function properly. If you can do it this way, that's definitely preferred. I was providing you with something that would work even without the separate boolean field.
If the cardinality of the field you're searching is very low (only a few possible values for that field across the whole index) then a wildcard query can be fast. It is only when the cardinality is high that the wildcard query is slow. Still, it is better to use the range query for determining whether the field exists, unless you have a separate boolean field for that purpose, in which case the boolean query will be a little bit faster.
Thanks, Shawn