Query on multi valued field

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

Query on multi valued field

Rajinimaski
Hi All,

       I have a specific requirement in the multi-valued field type.The
requirement is as follows

There is a multivalued field in each document which can have mutliple
elements or single element.

For Eg: Consider that following are the documents matched for say q= *:*

*DOC1*

 <doc>
<arr name="multi">
<str>1</str>
</arr>
</doc>
*
*
*DOC2*
<doc>
<arr name="multi">
<str>1</str>
<str>3</str>
<str>4</str>
</arr>
</doc>

*DOC3*
<doc>
<arr name="multi">
<str>1</str>
<str>2</str>
</arr>
</doc>

    The query is get only those documents which have multiple elements for
that multivalued field.

I.e, doc 2 and 3  should be returned from the above set..

Is there anyway to achieve this?


Awaiting reply,

Thanks & Regards,
Rajani
Reply | Threaded
Open this post in threaded view
|

Re: Query on multi valued field

Alexei Martchenko
have you tried multi:1 and multi:2 and multi:3 ?

2011/7/29 rajini maski <[hidden email]>

> Hi All,
>
>       I have a specific requirement in the multi-valued field type.The
> requirement is as follows
>
> There is a multivalued field in each document which can have mutliple
> elements or single element.
>
> For Eg: Consider that following are the documents matched for say q= *:*
>
> *DOC1*
>
>  <doc>
> <arr name="multi">
> <str>1</str>
> </arr>
> </doc>
> *
> *
> *DOC2*
> <doc>
> <arr name="multi">
> <str>1</str>
> <str>3</str>
> <str>4</str>
> </arr>
> </doc>
>
> *DOC3*
> <doc>
> <arr name="multi">
> <str>1</str>
> <str>2</str>
> </arr>
> </doc>
>
>    The query is get only those documents which have multiple elements for
> that multivalued field.
>
> I.e, doc 2 and 3  should be returned from the above set..
>
> Is there anyway to achieve this?
>
>
> Awaiting reply,
>
> Thanks & Regards,
> Rajani
>



--

*Alexei Martchenko* | *CEO* | Superdownloads
[hidden email] | [hidden email] | (11)
5083.1018/5080.3535/5080.3533
Reply | Threaded
Open this post in threaded view
|

Re: Query on multi valued field

Chris Hostetter-3
In reply to this post by Rajinimaski

:     The query is get only those documents which have multiple elements for
: that multivalued field.
:
: I.e, doc 2 and 3  should be returned from the above set..

The only way to do something like this is to add a field when you index
your documents that contains the number and then filter on that field
using a range query.

With an UpdateProcessor (or a ScriptTransformer in DIH) you can automate
counting how many values there are -- but it has to be indexed to
search/filter on it.



-Hoss
Reply | Threaded
Open this post in threaded view
|

Re: Query on multi valued field

Rajinimaski
Thank you. This logic works for me.

Thanks a lot.


Regards,
Rajani Maski




On Wed, Aug 3, 2011 at 1:21 AM, Chris Hostetter <[hidden email]>wrote:

>
> :     The query is get only those documents which have multiple elements
> for
> : that multivalued field.
> :
> : I.e, doc 2 and 3  should be returned from the above set..
>
> The only way to do something like this is to add a field when you index
> your documents that contains the number and then filter on that field
> using a range query.
>
> With an UpdateProcessor (or a ScriptTransformer in DIH) you can automate
> counting how many values there are -- but it has to be indexed to
> search/filter on it.
>
>
>
> -Hoss
>
Reply | Threaded
Open this post in threaded view
|

Re: Query on multi valued field

giridhar
In reply to this post by Rajinimaski
Hi,

I want to search in a multivalued field.

For example, my field FormIds contains (1,2,3) as comma separated.

If i search for 1 or (1,2) or (1,3) or (2,3) or (1,2,3) any combination like this should work.

How to define this multivalued integer field type.

Thankyou.
Reply | Threaded
Open this post in threaded view
|

Re: Query on multi valued field

Malcolm Upayavira Holmes
On Thu, Nov 14, 2013, at 03:45 PM, giridhar wrote:

> Hi,
>
> I want to search in a multivalued field.
>
> For example, my field FormIds contains (1,2,3) as comma separated.
>
> If i search for 1 or (1,2) or (1,3) or (2,3) or (1,2,3) any combination
> like
> this should work.
>
> How to define this multivalued integer field type.

Surely this is how multivalued fields work. If you had an integer field
type, that is defined as multiValued="true", then you can have three
values in that field, 1, 2 and 3.

Then, if you query for FormIds:(1 AND 2) will return all documents that
have both 1 and 2 in that field.

Am I missing something?

Upayavira
Reply | Threaded
Open this post in threaded view
|

Re: Query on multi valued field

Jack Krupansky-2
In reply to this post by giridhar
I suppose you could define the field as tokenized text with the work
delimiter filter and with autogeneratePhraseQueries="false" and the default
query operator set to OR, and then queries might just work close enough to
what you want.

Otherwise...

You could do a custom update processor that parsed the string and expands it
into separate integer values for a multivalued field, and then you would
need to do either a custom query parser or a query preprocessor that
exapanded that special syntax into normal  Solr query syntax using AND or OR
as desired.

You could implement the update processor as a JavaScript script. The
simplest approach to the query side would be to expand the special query
syntax in your application layer.

-- Jack Krupansky

-----Original Message-----
From: giridhar
Sent: Thursday, November 14, 2013 10:45 AM
To: [hidden email]
Subject: Re: Query on multi valued field

Hi,

I want to search in a multivalued field.

For example, my field FormIds contains (1,2,3) as comma separated.

If i search for 1 or (1,2) or (1,3) or (2,3) or (1,2,3) any combination like
this should work.

How to define this multivalued integer field type.

Thankyou.



--
View this message in context:
http://lucene.472066.n3.nabble.com/Query-on-multi-valued-field-tp3209343p4100937.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Query on multi valued field

Jack Krupansky-2
s/work/word/

"word delimiter filter"

-- Jack Krupansky

-----Original Message-----
From: Jack Krupansky
Sent: Thursday, November 14, 2013 11:34 AM
To: [hidden email]
Subject: Re: Query on multi valued field

I suppose you could define the field as tokenized text with the work
delimiter filter and with autogeneratePhraseQueries="false" and the default
query operator set to OR, and then queries might just work close enough to
what you want.

Otherwise...

You could do a custom update processor that parsed the string and expands it
into separate integer values for a multivalued field, and then you would
need to do either a custom query parser or a query preprocessor that
exapanded that special syntax into normal  Solr query syntax using AND or OR
as desired.

You could implement the update processor as a JavaScript script. The
simplest approach to the query side would be to expand the special query
syntax in your application layer.

-- Jack Krupansky

-----Original Message-----
From: giridhar
Sent: Thursday, November 14, 2013 10:45 AM
To: [hidden email]
Subject: Re: Query on multi valued field

Hi,

I want to search in a multivalued field.

For example, my field FormIds contains (1,2,3) as comma separated.

If i search for 1 or (1,2) or (1,3) or (2,3) or (1,2,3) any combination like
this should work.

How to define this multivalued integer field type.

Thankyou.



--
View this message in context:
http://lucene.472066.n3.nabble.com/Query-on-multi-valued-field-tp3209343p4100937.html
Sent from the Solr - User mailing list archive at Nabble.com.