You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Vasu Y <vy...@gmail.com> on 2016/07/21 10:44:24 UTC
Querying by a field value or if field doesn't exist
Hi,
I want to query for all documents where field "field1" contains a value
"value1" or the document doesn't contain the field "field1" at all.
I tried the query: "field1:value1 OR -field1:[* TO *]" and it didn't return
anything.
When I try them separately they work fine; "field1:value1" or the negative
query ("-field1:[* TO *]"), they work as desired.
Thanks,
Vasu
Re: Querying by a field value or if field doesn't exist
Posted by Erik Hatcher <er...@gmail.com>.
Vasu -
Try q=field1:value1 OR (*:* -field1:[* TO *])
Pure negative clause only works at the top-level / main query, otherwise need to do *:* and minus off stuff.
Erik
> On Jul 21, 2016, at 6:44 AM, Vasu Y <vy...@gmail.com> wrote:
>
> Hi,
> I want to query for all documents where field "field1" contains a value
> "value1" or the document doesn't contain the field "field1" at all.
>
>
> I tried the query: "field1:value1 OR -field1:[* TO *]" and it didn't return
> anything.
>
>
> When I try them separately they work fine; "field1:value1" or the negative
> query ("-field1:[* TO *]"), they work as desired.
>
> Thanks,
> Vasu