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 Utkarsh Sengar <ut...@gmail.com> on 2013/08/14 20:37:17 UTC

Load a list of values in a solr field and query over its items

Hello,

Is it possible to load a list in a solr filed and query for items in that
list?

example_core1:

document1:
FieldName=user_ids
Value=8,6,1,9,3,5,7
FieldName=allText
Value=text to be searched over with title and description

document2:
FieldName=user_ids
Value=8738,624623,7272.82272,733
FieldName=allText
Value=more text for document2

Query: allText:hello
fq:user_ids:8,8738

Result: All documents who have the text "hello" in allText and userId=8

If this is not possible, what is a better way to solve this problem?

-- 
Thanks,
-Utkarsh

Re: Load a list of values in a solr field and query over its items

Posted by Utkarsh Sengar <ut...@gmail.com>.
Never mind,got my answer here: http://stackoverflow.com/a/5800830/231917

<field name="tags">tag1</tags>
<field name="tags">tag2</tags>
...
<field name="tags">tagn</tags>

once you have all the values index you can search or filter results by any
value, e,g. you can find all documents with tag1 using query like

q=tags:tag1

or use the tags to filter out results like

q=query&fq=tags:tag1


Thanks!

-Utkarsh


On Wed, Aug 14, 2013 at 11:57 AM, Utkarsh Sengar <ut...@gmail.com>wrote:

> Thanks Aloke!
>
> So a multivalued field assumes:
>
> 1. if data is inserted in this form: "8738,624623,7272,82272,733", there
> are 5 unique values separated by a comma (or any other separator)?
> 2. And a filter query can be applied over it?
>
> Thanks,
> -Utkarsh
>
>
>
> On Wed, Aug 14, 2013 at 11:45 AM, Aloke Ghoshal <al...@gmail.com>wrote:
>
>> Should work once you set up both fields as multiValued (
>> http://wiki.apache.org/solr/SchemaXml#Common_field_options).
>>
>>
>> On Thu, Aug 15, 2013 at 12:07 AM, Utkarsh Sengar <utkarsh2012@gmail.com
>> >wrote:
>>
>> > Hello,
>> >
>> > Is it possible to load a list in a solr filed and query for items in
>> that
>> > list?
>> >
>> > example_core1:
>> >
>> > document1:
>> > FieldName=user_ids
>> > Value=8,6,1,9,3,5,7
>> > FieldName=allText
>> > Value=text to be searched over with title and description
>> >
>> > document2:
>> > FieldName=user_ids
>> > Value=8738,624623,7272.82272,733
>> > FieldName=allText
>> > Value=more text for document2
>> >
>> > Query: allText:hello
>> > fq:user_ids:8,8738
>> >
>> > Result: All documents who have the text "hello" in allText and userId=8
>> >
>> > If this is not possible, what is a better way to solve this problem?
>> >
>> > --
>> > Thanks,
>> > -Utkarsh
>> >
>>
>
>
>
> --
> Thanks,
> -Utkarsh
>



-- 
Thanks,
-Utkarsh

Re: Load a list of values in a solr field and query over its items

Posted by Utkarsh Sengar <ut...@gmail.com>.
Thanks Aloke!

So a multivalued field assumes:

1. if data is inserted in this form: "8738,624623,7272,82272,733", there
are 5 unique values separated by a comma (or any other separator)?
2. And a filter query can be applied over it?

Thanks,
-Utkarsh



On Wed, Aug 14, 2013 at 11:45 AM, Aloke Ghoshal <al...@gmail.com> wrote:

> Should work once you set up both fields as multiValued (
> http://wiki.apache.org/solr/SchemaXml#Common_field_options).
>
>
> On Thu, Aug 15, 2013 at 12:07 AM, Utkarsh Sengar <utkarsh2012@gmail.com
> >wrote:
>
> > Hello,
> >
> > Is it possible to load a list in a solr filed and query for items in that
> > list?
> >
> > example_core1:
> >
> > document1:
> > FieldName=user_ids
> > Value=8,6,1,9,3,5,7
> > FieldName=allText
> > Value=text to be searched over with title and description
> >
> > document2:
> > FieldName=user_ids
> > Value=8738,624623,7272.82272,733
> > FieldName=allText
> > Value=more text for document2
> >
> > Query: allText:hello
> > fq:user_ids:8,8738
> >
> > Result: All documents who have the text "hello" in allText and userId=8
> >
> > If this is not possible, what is a better way to solve this problem?
> >
> > --
> > Thanks,
> > -Utkarsh
> >
>



-- 
Thanks,
-Utkarsh

Re: Load a list of values in a solr field and query over its items

Posted by Aloke Ghoshal <al...@gmail.com>.
Should work once you set up both fields as multiValued (
http://wiki.apache.org/solr/SchemaXml#Common_field_options).


On Thu, Aug 15, 2013 at 12:07 AM, Utkarsh Sengar <ut...@gmail.com>wrote:

> Hello,
>
> Is it possible to load a list in a solr filed and query for items in that
> list?
>
> example_core1:
>
> document1:
> FieldName=user_ids
> Value=8,6,1,9,3,5,7
> FieldName=allText
> Value=text to be searched over with title and description
>
> document2:
> FieldName=user_ids
> Value=8738,624623,7272.82272,733
> FieldName=allText
> Value=more text for document2
>
> Query: allText:hello
> fq:user_ids:8,8738
>
> Result: All documents who have the text "hello" in allText and userId=8
>
> If this is not possible, what is a better way to solve this problem?
>
> --
> Thanks,
> -Utkarsh
>