: I would like to search for all documents with a field not defined.
: Say You have documents with title_s defined and some documents without
: title_s: I would like to obtain all documents without title_s.
:
: I've not find a clue, perhaps it's not possible; I would like to know if
: there is an alternative to setting a default value "undefined" for title_s
: on all documents.

This is a fairly common problem with lucene -- selecting the inverse of a
query is hard, because you have to positively select something beore you
can exclude things.

There are some tricks for doing this in Solr if you are writing your own
plugin using DocSets and BitSets, but if you're just using the
StandardRequestHandler then one thing you can do if you've got a field
that always contains at least one indexed value for every doc in your
index (like a uniqueKey field for example) is to use an unbounded range
query on your uniqueKey field to select every document, and then add a
prohibited clause on an unbounded range query for the field you want to
find missing values in, something like this...

   +uniqueKey:[* TO *] -title_s:[* TO *]

...normally in lucene really big range queries are dangerous, but Solr
turns them into ConstantScoreRangeQueries under the covers for you so
there's no big penalty.


-Hoss

Reply via email to