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 Thiago Jackiw <tj...@gmail.com> on 2007/06/21 01:00:41 UTC
Rejecting fields with null values
I'm not sure if this is possible or not, but, is there a way to do a
search and reject fields that are empty or have null values like the
pseudo code below?
?q=test+AND+(NOT+field_b:NULL)
If this is not currently supported, does anyone think this is not a
god idea to be implemented?
Thanks,
--
Thiago Jackiw
acts_as_solr => http://acts-as-solr.railsfreaks.com
Re: Rejecting fields with null values
Posted by Yonik Seeley <yo...@apache.org>.
Keep in mind filters too... they can be much more efficient if used often:
?q=test&fq=field_b:[* TO *]
-Yonik
On 6/20/07, Thiago Jackiw <tj...@gmail.com> wrote:
> Hoss,
>
> > As an inverted index, the Lucene index Solr uses doesn't know when
> > documents have an "empty" value ... it stores the inverted mapping of
> > value=>documents, so there is no way to query for field_b:NULL, let alone
> > "NOT field_b:bull"
>
> I see what you mean. I guess searching for fields that require to
> have a value like the way you explained is a good way to go.
>
> Thanks!
>
> --
> Thiago Jackiw
> acts_as_solr => http://acts-as-solr.railsfreaks.com
>
>
> On 6/20/07, Chris Hostetter <ho...@fucit.org> wrote:
> > : I'm not sure if this is possible or not, but, is there a way to do a
> > : search and reject fields that are empty or have null values like the
> > : pseudo code below?
> >
> > As an inverted index, the Lucene index Solr uses doesn't know when
> > documents have an "empty" value ... it stores the inverted mapping of
> > value=>documents, so there is no way to query for field_b:NULL, let alone
> > "NOT field_b:bull"
> >
> > you can however query forthings like: field_b:[* TO *] which requres
> > field_b to have some value (that seems to be the use case you are after)
> >
> > as a general rule, if you really want to be abel to support searches for
> > rhings like "find all docs wher there is no value in field X" the easiest
> > way to achieve something like that in Solr is to configure the field with
> > a default value in the schema ... something that would never normally
> > appear in your data (a placeholder for 'null' so to speak) and query on
> > that.
> >
> >
> > -Hoss
> >
> >
>
Re: Rejecting fields with null values
Posted by Thiago Jackiw <tj...@gmail.com>.
Hoss,
> As an inverted index, the Lucene index Solr uses doesn't know when
> documents have an "empty" value ... it stores the inverted mapping of
> value=>documents, so there is no way to query for field_b:NULL, let alone
> "NOT field_b:bull"
I see what you mean. I guess searching for fields that require to
have a value like the way you explained is a good way to go.
Thanks!
--
Thiago Jackiw
acts_as_solr => http://acts-as-solr.railsfreaks.com
On 6/20/07, Chris Hostetter <ho...@fucit.org> wrote:
> : I'm not sure if this is possible or not, but, is there a way to do a
> : search and reject fields that are empty or have null values like the
> : pseudo code below?
>
> As an inverted index, the Lucene index Solr uses doesn't know when
> documents have an "empty" value ... it stores the inverted mapping of
> value=>documents, so there is no way to query for field_b:NULL, let alone
> "NOT field_b:bull"
>
> you can however query forthings like: field_b:[* TO *] which requres
> field_b to have some value (that seems to be the use case you are after)
>
> as a general rule, if you really want to be abel to support searches for
> rhings like "find all docs wher there is no value in field X" the easiest
> way to achieve something like that in Solr is to configure the field with
> a default value in the schema ... something that would never normally
> appear in your data (a placeholder for 'null' so to speak) and query on
> that.
>
>
> -Hoss
>
>
Re: Rejecting fields with null values
Posted by Chris Hostetter <ho...@fucit.org>.
: I'm not sure if this is possible or not, but, is there a way to do a
: search and reject fields that are empty or have null values like the
: pseudo code below?
As an inverted index, the Lucene index Solr uses doesn't know when
documents have an "empty" value ... it stores the inverted mapping of
value=>documents, so there is no way to query for field_b:NULL, let alone
"NOT field_b:bull"
you can however query forthings like: field_b:[* TO *] which requres
field_b to have some value (that seems to be the use case you are after)
as a general rule, if you really want to be abel to support searches for
rhings like "find all docs wher there is no value in field X" the easiest
way to achieve something like that in Solr is to configure the field with
a default value in the schema ... something that would never normally
appear in your data (a placeholder for 'null' so to speak) and query on
that.
-Hoss