Rejecting fields with null values

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Rejecting fields with null values

Thiago Jackiw-2
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
Reply | Threaded
Open this post in threaded view
|

Re: Rejecting fields with null values

Chris Hostetter-3
: 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

Reply | Threaded
Open this post in threaded view
|

Re: Rejecting fields with null values

Thiago Jackiw-2
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 <[hidden email]> 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
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Rejecting fields with null values

Yonik Seeley-2
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 <[hidden email]> 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 <[hidden email]> 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
> >
> >
>