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 Wei <we...@gmail.com> on 2018/06/19 06:20:50 UTC
How to exclude certain values in multi-value field filter query
Hi,
I have a multi-value field, and there is a limited set of values for the
field: A, B, C, D.
Is there a way to filter out documents that has only A or B values in the
multi-value field?
Basically I want to exclude document that has:
A
B
A B
and get documents that has:
C
D
C D
A C
B C
A D
B D
A B C
A B D
A C D
B C D
A B C D
Thanks,
Wei
Re: How to exclude certain values in multi-value field filter query
Posted by Wei <we...@gmail.com>.
Thanks Mikhail and Alessandro.
On Tue, Jun 19, 2018 at 2:37 AM, Mikhail Khludnev <mk...@apache.org> wrote:
> you need to index num vals
> <https://lucene.apache.org/solr/7_1_0//solr-core/org/
> apache/solr/update/processor/CountFieldValuesUpdateProcessorFactory.html>
> in the separate field, and then *:* -(V:(A AND B) AND numVals:2) -(V:(A OR
> B) AND numVals:1)
>
>
> On Tue, Jun 19, 2018 at 9:20 AM Wei <we...@gmail.com> wrote:
>
> > Hi,
> >
> > I have a multi-value field, and there is a limited set of values for the
> > field: A, B, C, D.
> > Is there a way to filter out documents that has only A or B values in the
> > multi-value field?
> >
> > Basically I want to exclude document that has:
> >
> > A
> >
> > B
> >
> > A B
> >
> > and get documents that has:
> >
> >
> > C
> >
> > D
> >
> > C D
> >
> > A C
> >
> > B C
> >
> > A D
> >
> > B D
> >
> > A B C
> >
> > A B D
> >
> > A C D
> >
> > B C D
> >
> > A B C D
> >
> >
> > Thanks,
> >
> > Wei
> >
>
>
> --
> Sincerely yours
> Mikhail Khludnev
>
Re: How to exclude certain values in multi-value field filter query
Posted by Mikhail Khludnev <mk...@apache.org>.
you need to index num vals
<https://lucene.apache.org/solr/7_1_0//solr-core/org/apache/solr/update/processor/CountFieldValuesUpdateProcessorFactory.html>
in the separate field, and then *:* -(V:(A AND B) AND numVals:2) -(V:(A OR
B) AND numVals:1)
On Tue, Jun 19, 2018 at 9:20 AM Wei <we...@gmail.com> wrote:
> Hi,
>
> I have a multi-value field, and there is a limited set of values for the
> field: A, B, C, D.
> Is there a way to filter out documents that has only A or B values in the
> multi-value field?
>
> Basically I want to exclude document that has:
>
> A
>
> B
>
> A B
>
> and get documents that has:
>
>
> C
>
> D
>
> C D
>
> A C
>
> B C
>
> A D
>
> B D
>
> A B C
>
> A B D
>
> A C D
>
> B C D
>
> A B C D
>
>
> Thanks,
>
> Wei
>
--
Sincerely yours
Mikhail Khludnev
Re: How to exclude certain values in multi-value field filter query
Posted by Alessandro Benedetti <a....@sease.io>.
The first idea that comes in my mind is to build a single valued copy field
which concatenates them.
in this way you will have very specific values to filter on :
query1 -(copyfield:(A B AB))
To concatenate you can use this update request processor :
https://lucene.apache.org/solr/6_6_0//solr-core/org/apache/solr/update/processor/ConcatFieldUpdateProcessorFactory.html
Regards
-----
---------------
Alessandro Benedetti
Search Consultant, R&D Software Engineer, Director
Sease Ltd. - www.sease.io
--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html