How to exclude certain values in multi-value field filter query

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

How to exclude certain values in multi-value field filter query

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

Re: How to exclude certain values in multi-value field filter query

Alessandro Benedetti
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
---------------
Alessandro Benedetti
Search Consultant, R&D Software Engineer, Director
Sease Ltd. - www.sease.io
Reply | Threaded
Open this post in threaded view
|

Re: How to exclude certain values in multi-value field filter query

Mikhail Khludnev-2
In reply to this post by weiwang19
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 <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: How to exclude certain values in multi-value field filter query

weiwang19
Thanks Mikhail and Alessandro.

On Tue, Jun 19, 2018 at 2:37 AM, Mikhail Khludnev <[hidden email]> 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 <[hidden email]> 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
>