How do I search for those document in a SOLR index which do not contain a specified field?
Asked
Active
Viewed 4.3k times
1 Answers
71
-field:[* TO *]
In SolrNet, use a negated SolrHasValueQuery

None
- 5,582
- 21
- 85
- 170

Mauricio Scheffer
- 98,863
- 23
- 192
- 275
-
3That's insanely expensive. There has to be a better way, but I haven't looked yet. At minimum, you should create an empty field marker (e.g. NULL) and index that. – Kyle Maxwell Dec 19 '12 at 21:38
-
1@KyleMaxwell of course, doing it at index-time is better... if not, I don't think there's a better way to do it at query-time. – Mauricio Scheffer Dec 19 '12 at 23:14
-
5Note this only works for fields that are indexed. Doing this for non-indexed fields will returns all records. – Rodney Gitzel Feb 26 '13 at 01:14
-
1I've tested this request directly on a fairly large index and it is not that expensive (with solr 4.10 and on a docvalues field) – Stephan L Mar 23 '15 at 17:01
-
7we can use -field:* also – Ambika May 16 '16 at 06:08