You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Vlad K <ku...@gmail.com> on 2015/11/11 22:43:05 UTC
Query documents where Field Doesn't Exist
Hello,
I read some discussions at Internet and still don't see if there is an
official Lucene's solution to support: "query documents where Field Doesn't
exist"
Do you know if there is some recommended solution?
Thanks,
Vladimir Kuzmin
Re: Query documents where Field Doesn't Exist
Posted by Vlad K <ku...@gmail.com>.
Hi Adrien, I had a chance to test and I see that there is one more
solution. For fields that we want to search for exist/doesn't exist add one
more indexed field, like "ex_field=1" and can search by: +ex_field=1 or
-ex_field=1. It works fast.
On Fri, Nov 13, 2015 at 5:21 AM, Adrien Grand <jp...@gmail.com> wrote:
> Hi Vlad,
>
> This is something that you generally can't do. If you have doc values
> enabled on your fields, you can use Lucene's FieldValueQuery, but beware
> that this query is very slow. Otherwise if your field is indexed, you can
> run a TermRangeQuery that has both bounds open but this will be even slower
> (and by that I mean that this could never return on a large index). So
> generally the best way to address this problem is to solve it by indexing a
> meta-data field that contains the list of the fields that a document
> contains. Then you can filter documents that have a field or not by running
> a TermQuery against this field.
>
>
> Le mer. 11 nov. 2015 à 22:43, Vlad K <ku...@gmail.com> a écrit :
>
> > Hello,
> >
> > I read some discussions at Internet and still don't see if there is an
> > official Lucene's solution to support: "query documents where Field
> Doesn't
> > exist"
> >
> > Do you know if there is some recommended solution?
> >
> > Thanks,
> > Vladimir Kuzmin
> >
>
Re: Query documents where Field Doesn't Exist
Posted by Adrien Grand <jp...@gmail.com>.
Hi Vlad,
This is something that you generally can't do. If you have doc values
enabled on your fields, you can use Lucene's FieldValueQuery, but beware
that this query is very slow. Otherwise if your field is indexed, you can
run a TermRangeQuery that has both bounds open but this will be even slower
(and by that I mean that this could never return on a large index). So
generally the best way to address this problem is to solve it by indexing a
meta-data field that contains the list of the fields that a document
contains. Then you can filter documents that have a field or not by running
a TermQuery against this field.
Le mer. 11 nov. 2015 à 22:43, Vlad K <ku...@gmail.com> a écrit :
> Hello,
>
> I read some discussions at Internet and still don't see if there is an
> official Lucene's solution to support: "query documents where Field Doesn't
> exist"
>
> Do you know if there is some recommended solution?
>
> Thanks,
> Vladimir Kuzmin
>