Hi,

Using Solr 1.4 I wanted to construct a query that returns documents that
have a particular field value or are missing the field. The first thing I
came up with was:

field1:particularvalue OR -field1:[* TO *]

It turns out the -field1:[* TO *] was being ignored. If particularvalue
wasn't found, for instance, it returned 0 hits.

Well after a lot of experimentation I found a query that works as expected:

field1:particularvalue OR (*:* AND -field1:[* TO *])

It seems like a hack though. Am I approaching this the wrong way? What's the
recommended way for doing this type of search?

In case it matters, field1's fieldType is:

<fieldType name="string" class="solr.StrField" sortMissingLast="true"
omitNorms="true"/>

And it's actually a dynamic field defined like this:

<dynamicField name="*_string"  type="string"  indexed="true"  stored="false"
multiValued="true"/>

Reply via email to