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 Brian Lamb <br...@journalexperts.com> on 2011/07/25 17:53:14 UTC

Ignore records that are missing a value in a field

Hi all,

I have an optional field called "common_names". I would like to keep this
field optional but at the same, occasionally do a search where I do not
include results where there is no value set for this field. Is this possible
to do within solr?

In other words, I would like to do a search where if there is no value set
for common_names, I would not want that record included in the search
result.

Thanks,

Brian Lamb

Re: Ignore records that are missing a value in a field

Posted by Erick Erickson <er...@gmail.com>.
Hmmm, I think that should be fq=field:[* TO *] since the problem is to
include docs with anything in that field.

You could also index a special "EMPTY_FIELD" string and do something
like fq=-field:[EMPTY_FIELD]..

Best
Erick

On Mon, Jul 25, 2011 at 12:10 PM, Stefan Matheis
<ma...@googlemail.com> wrote:
> So, with other words you want to exlude those records? :)
> FilterQuery with a Range-Query could help: fq=-field:[* TO *]
>
> Regards
> Stefan
>
> Am 25.07.2011 17:53, schrieb Brian Lamb:
>>
>> Hi all,
>>
>> I have an optional field called "common_names". I would like to keep this
>> field optional but at the same, occasionally do a search where I do not
>> include results where there is no value set for this field. Is this
>> possible
>> to do within solr?
>>
>> In other words, I would like to do a search where if there is no value set
>> for common_names, I would not want that record included in the search
>> result.
>>
>> Thanks,
>>
>> Brian Lamb
>>
>

Re: Ignore records that are missing a value in a field

Posted by Stefan Matheis <ma...@googlemail.com>.
So, with other words you want to exlude those records? :)
FilterQuery with a Range-Query could help: fq=-field:[* TO *]

Regards
Stefan

Am 25.07.2011 17:53, schrieb Brian Lamb:
> Hi all,
>
> I have an optional field called "common_names". I would like to keep this
> field optional but at the same, occasionally do a search where I do not
> include results where there is no value set for this field. Is this possible
> to do within solr?
>
> In other words, I would like to do a search where if there is no value set
> for common_names, I would not want that record included in the search
> result.
>
> Thanks,
>
> Brian Lamb
>