0

I need to get all documents where field 'status' is either empty or has the value 'active'

I tried

status:active OR (NOT status:*)
status:active OR (NOT status:[* TO *])
status:(active OR NOT *)

All of these variants don't work.

valeryz
  • 71
  • 1
  • 4

3 Answers3

0

Try this one

-status:[* TO *] OR status:active
udalmik
  • 7,838
  • 26
  • 40
  • Unfortunately, zero results. Each of the terms works as expected, but when combined with OR, it looks like they are combined with AND in fact. – valeryz Aug 23 '12 at 17:27
  • Hmm... maybe (-status:[* TO *] OR status:active)? – udalmik Aug 23 '12 at 17:31
  • Tried this too, doesn't work. I will probably amend the field at index time so that it is not empty. – valeryz Aug 23 '12 at 19:06
  • The above query is correct though. Not sure why it is not working for you. e.g. q=-status:[* TO *] OR status:active. The fields should be indexed and it should work fine. – Jayendra Aug 24 '12 at 06:45
0

Try the following query.

-(status:['' TO *] OR -status:active)
Parvin Gasimzade
  • 25,180
  • 8
  • 56
  • 83
0

This should do the trick (ref. https://stackoverflow.com/a/35633038/13365):

status:active OR (*:* NOT status:["" TO *])

I never got the -status versions to work.

Community
  • 1
  • 1
neu242
  • 15,796
  • 20
  • 79
  • 114