Multi valued fields

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

Multi valued fields

Jean-Sebastien Vachon
Hi All,

I'd like to know if it is possible to do the following on a multi-value field:

Given the following data:

document A:  field1   = [ A B C D]
document B:  field 1  = [A B]
document C:  field 1  = [A]

Can I build a query such as :

        -field: A

which will return all documents that do not have "exclusive" A in the their field's values. By exclusive I mean that I don't want documents that only have A in their list of values. In my sample case, the query would return doc A and B.
Because they both have other values in field1.

It this kind of query possible with Solr/Lucene?

Thanks



Reply | Threaded
Open this post in threaded view
|

Re: Multi valued fields

Lance Norskog-2
This could be done with a function query, except that the function I
would use does not exist.  There is no function that returns the
number of values that exist for a field. If there were, you could say:

-field:A OR (field:A and function() > 1)

I don't know the Lucene data structures well, but I suspect this would
be incredibly expensive to calculate.

On 3/11/10, Jean-Sebastien Vachon <[hidden email]> wrote:

> Hi All,
>
> I'd like to know if it is possible to do the following on a multi-value
> field:
>
> Given the following data:
>
> document A:  field1   = [ A B C D]
> document B:  field 1  = [A B]
> document C:  field 1  = [A]
>
> Can I build a query such as :
>
> -field: A
>
> which will return all documents that do not have "exclusive" A in the their
> field's values. By exclusive I mean that I don't want documents that only
> have A in their list of values. In my sample case, the query would return
> doc A and B.
> Because they both have other values in field1.
>
> It this kind of query possible with Solr/Lucene?
>
> Thanks
>
>
>
>


--
Lance Norskog
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Multi valued fields

hossman
In reply to this post by Jean-Sebastien Vachon

: Can I build a query such as :
:
: -field: A
:
: which will return all documents that do not have "exclusive" A in the
: their field's values. By exclusive I mean that I don't want documents
: that only have A in their list of values. In my sample case, the query
: would return doc A and B. Because they both have other values in field1.

the most straight forward way i know of to deal with requirements like
this is to also have a field_count field where you record the number of
values indexed into "field" ... an UpdateProcessor can automate creating
this field for you, and then you can query for something like...

        -(+field:A +field_count:1)


-Hoss