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 rajini maski <ra...@gmail.com> on 2011/07/29 13:19:34 UTC
Query on multi valued field
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
Re: Query on multi valued field
Posted by Jack Krupansky <ja...@basetechnology.com>.
s/work/word/
"word delimiter filter"
-- Jack Krupansky
-----Original Message-----
From: Jack Krupansky
Sent: Thursday, November 14, 2013 11:34 AM
To: solr-user@lucene.apache.org
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: solr-user@lucene.apache.org
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.
Re: Query on multi valued field
Posted by Jack Krupansky <ja...@basetechnology.com>.
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: solr-user@lucene.apache.org
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.
Re: Query on multi valued field
Posted by Upayavira <uv...@odoko.co.uk>.
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
Re: Query on multi valued field
Posted by giridhar <gi...@gmail.com>.
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.
Re: Query on multi valued field
Posted by rajini maski <ra...@gmail.com>.
Thank you. This logic works for me.
Thanks a lot.
Regards,
Rajani Maski
On Wed, Aug 3, 2011 at 1:21 AM, Chris Hostetter <ho...@fucit.org>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
>
Re: Query on multi valued field
Posted by Chris Hostetter <ho...@fucit.org>.
: 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
Re: Query on multi valued field
Posted by Alexei Martchenko <al...@superdownloads.com.br>.
have you tried multi:1 and multi:2 and multi:3 ?
2011/7/29 rajini maski <ra...@gmail.com>
> 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
alexei@superdownloads.com.br | alexei@martchenko.com.br | (11)
5083.1018/5080.3535/5080.3533