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 Abhishek tiwari <ab...@gmail.com> on 2012/03/28 15:02:48 UTC

query help

Hi ,
i have multi valued field want to sort the docs order the particular
text eq:'B1' is added.
how i should query? ad_text is multivalued field.

t

<doc>
<arr name="ad_text">
<str>B1</str>
<str>B2</str>
<str>B3</str>
</arr>
</doc>
<doc>
<arr name="ad_text">
<str>B2</str>
<str>B1</str>
<str>B3</str>
</arr>
</doc>

<doc>
<arr name="ad_text">
<str>B1</str>
<str>B2</str>
<str>B3</str>
</arr>
</doc>
<doc>
<arr name="ad_text">
<str>B3</str>
<str>B2</str>
<str>B1</str>
</arr>
</doc>

Re: query help

Posted by Erick Erickson <er...@gmail.com>.
Boosting won't help either I don't think. Boosts apply to the
document, and pretty much ignore position information.

Best
Erick

On Thu, Mar 29, 2012 at 2:07 PM, Abhishek tiwari
<ab...@gmail.com> wrote:
> can i achieve this with help of  boosting technique ?
>
> On Thu, Mar 29, 2012 at 10:42 PM, Erick Erickson <er...@gmail.com>wrote:
>
>> Solr doesn't support sorting on multValued fields so I don't think this
>> is possible OOB.
>>
>> I can't come up with a clever indexing solution that does this either,
>> sorry.
>>
>> Best
>> Erick
>>
>> On Thu, Mar 29, 2012 at 8:27 AM, Abhishek tiwari
>> <ab...@gmail.com> wrote:
>> > a) No. i do not want to sort the content within document .
>> > I want to sort the documents .
>> > b) As i have explained i have result set( documents ) and each document
>> > contains a fields "*ad_text*" (with other fields also) which is
>> > multivalued..storing some tags say "B1, B2, B3" in each. bt order of tags
>> > are different for each doc. say (B1, B2, B3) *for doc1*,  B3,B1 B2*, for
>> > doc2*, B1, B3, B2*, doc3*, B2, B3, B1* for doc4*
>> >
>> > if i search for B1: result should come in following order:
>> > doc1,doc3,doc2,doc4
>> > (As B1 is first value in maltivalued result for doc1and doc3, and B1 is
>> in
>> > 2nd value in doc2 while  B1 is at 3rd in doc4  )
>> > if i search for B2: result should come in following order: doc4
>> > ,doc1,doc3,doc2
>> >
>> >
>> > I donot know whether it is possible or not ..
>> >
>> > but please suggest how it can be done.
>> >
>> >
>> >
>> > On Thu, Mar 29, 2012 at 5:18 PM, Erick Erickson <erickerickson@gmail.com
>> >wrote:
>> >
>> >> Hmmm, I don't quite get this. Are you saying that you want
>> >> to sort the documents or sort the content within the document?
>> >>
>> >> Sorting documents (i.e the results list) requires a single-valued
>> >> field. So you'd have to, at index time, sort the entries.
>> >>
>> >> Sorting the content within the document is something you'd
>> >> have to do when you index, Solr doesn't rearrange the
>> >> contents of a document.
>> >>
>> >> If all you want to do is display the results within the document
>> >> in order, your app can do that as it builds the display page.
>> >>
>> >> Best
>> >> Erick
>> >>
>> >> On Wed, Mar 28, 2012 at 9:02 AM, Abhishek tiwari
>> >> <ab...@gmail.com> wrote:
>> >> > Hi ,
>> >> > i have multi valued field want to sort the docs order the particular
>> >> > text eq:'B1' is added.
>> >> > how i should query? ad_text is multivalued field.
>> >> >
>> >> > t
>> >> >
>> >> > <doc>
>> >> > <arr name="ad_text">
>> >> > <str>B1</str>
>> >> > <str>B2</str>
>> >> > <str>B3</str>
>> >> > </arr>
>> >> > </doc>
>> >> > <doc>
>> >> > <arr name="ad_text">
>> >> > <str>B2</str>
>> >> > <str>B1</str>
>> >> > <str>B3</str>
>> >> > </arr>
>> >> > </doc>
>> >> >
>> >> > <doc>
>> >> > <arr name="ad_text">
>> >> > <str>B1</str>
>> >> > <str>B2</str>
>> >> > <str>B3</str>
>> >> > </arr>
>> >> > </doc>
>> >> > <doc>
>> >> > <arr name="ad_text">
>> >> > <str>B3</str>
>> >> > <str>B2</str>
>> >> > <str>B1</str>
>> >> > </arr>
>> >> > </doc>
>> >>
>>

Re: query help

Posted by Abhishek tiwari <ab...@gmail.com>.
can i achieve this with help of  boosting technique ?

On Thu, Mar 29, 2012 at 10:42 PM, Erick Erickson <er...@gmail.com>wrote:

> Solr doesn't support sorting on multValued fields so I don't think this
> is possible OOB.
>
> I can't come up with a clever indexing solution that does this either,
> sorry.
>
> Best
> Erick
>
> On Thu, Mar 29, 2012 at 8:27 AM, Abhishek tiwari
> <ab...@gmail.com> wrote:
> > a) No. i do not want to sort the content within document .
> > I want to sort the documents .
> > b) As i have explained i have result set( documents ) and each document
> > contains a fields "*ad_text*" (with other fields also) which is
> > multivalued..storing some tags say "B1, B2, B3" in each. bt order of tags
> > are different for each doc. say (B1, B2, B3) *for doc1*,  B3,B1 B2*, for
> > doc2*, B1, B3, B2*, doc3*, B2, B3, B1* for doc4*
> >
> > if i search for B1: result should come in following order:
> > doc1,doc3,doc2,doc4
> > (As B1 is first value in maltivalued result for doc1and doc3, and B1 is
> in
> > 2nd value in doc2 while  B1 is at 3rd in doc4  )
> > if i search for B2: result should come in following order: doc4
> > ,doc1,doc3,doc2
> >
> >
> > I donot know whether it is possible or not ..
> >
> > but please suggest how it can be done.
> >
> >
> >
> > On Thu, Mar 29, 2012 at 5:18 PM, Erick Erickson <erickerickson@gmail.com
> >wrote:
> >
> >> Hmmm, I don't quite get this. Are you saying that you want
> >> to sort the documents or sort the content within the document?
> >>
> >> Sorting documents (i.e the results list) requires a single-valued
> >> field. So you'd have to, at index time, sort the entries.
> >>
> >> Sorting the content within the document is something you'd
> >> have to do when you index, Solr doesn't rearrange the
> >> contents of a document.
> >>
> >> If all you want to do is display the results within the document
> >> in order, your app can do that as it builds the display page.
> >>
> >> Best
> >> Erick
> >>
> >> On Wed, Mar 28, 2012 at 9:02 AM, Abhishek tiwari
> >> <ab...@gmail.com> wrote:
> >> > Hi ,
> >> > i have multi valued field want to sort the docs order the particular
> >> > text eq:'B1' is added.
> >> > how i should query? ad_text is multivalued field.
> >> >
> >> > t
> >> >
> >> > <doc>
> >> > <arr name="ad_text">
> >> > <str>B1</str>
> >> > <str>B2</str>
> >> > <str>B3</str>
> >> > </arr>
> >> > </doc>
> >> > <doc>
> >> > <arr name="ad_text">
> >> > <str>B2</str>
> >> > <str>B1</str>
> >> > <str>B3</str>
> >> > </arr>
> >> > </doc>
> >> >
> >> > <doc>
> >> > <arr name="ad_text">
> >> > <str>B1</str>
> >> > <str>B2</str>
> >> > <str>B3</str>
> >> > </arr>
> >> > </doc>
> >> > <doc>
> >> > <arr name="ad_text">
> >> > <str>B3</str>
> >> > <str>B2</str>
> >> > <str>B1</str>
> >> > </arr>
> >> > </doc>
> >>
>

Re: query help

Posted by Erick Erickson <er...@gmail.com>.
Solr doesn't support sorting on multValued fields so I don't think this
is possible OOB.

I can't come up with a clever indexing solution that does this either, sorry.

Best
Erick

On Thu, Mar 29, 2012 at 8:27 AM, Abhishek tiwari
<ab...@gmail.com> wrote:
> a) No. i do not want to sort the content within document .
> I want to sort the documents .
> b) As i have explained i have result set( documents ) and each document
> contains a fields "*ad_text*" (with other fields also) which is
> multivalued..storing some tags say "B1, B2, B3" in each. bt order of tags
> are different for each doc. say (B1, B2, B3) *for doc1*,  B3,B1 B2*, for
> doc2*, B1, B3, B2*, doc3*, B2, B3, B1* for doc4*
>
> if i search for B1: result should come in following order:
> doc1,doc3,doc2,doc4
> (As B1 is first value in maltivalued result for doc1and doc3, and B1 is in
> 2nd value in doc2 while  B1 is at 3rd in doc4  )
> if i search for B2: result should come in following order: doc4
> ,doc1,doc3,doc2
>
>
> I donot know whether it is possible or not ..
>
> but please suggest how it can be done.
>
>
>
> On Thu, Mar 29, 2012 at 5:18 PM, Erick Erickson <er...@gmail.com>wrote:
>
>> Hmmm, I don't quite get this. Are you saying that you want
>> to sort the documents or sort the content within the document?
>>
>> Sorting documents (i.e the results list) requires a single-valued
>> field. So you'd have to, at index time, sort the entries.
>>
>> Sorting the content within the document is something you'd
>> have to do when you index, Solr doesn't rearrange the
>> contents of a document.
>>
>> If all you want to do is display the results within the document
>> in order, your app can do that as it builds the display page.
>>
>> Best
>> Erick
>>
>> On Wed, Mar 28, 2012 at 9:02 AM, Abhishek tiwari
>> <ab...@gmail.com> wrote:
>> > Hi ,
>> > i have multi valued field want to sort the docs order the particular
>> > text eq:'B1' is added.
>> > how i should query? ad_text is multivalued field.
>> >
>> > t
>> >
>> > <doc>
>> > <arr name="ad_text">
>> > <str>B1</str>
>> > <str>B2</str>
>> > <str>B3</str>
>> > </arr>
>> > </doc>
>> > <doc>
>> > <arr name="ad_text">
>> > <str>B2</str>
>> > <str>B1</str>
>> > <str>B3</str>
>> > </arr>
>> > </doc>
>> >
>> > <doc>
>> > <arr name="ad_text">
>> > <str>B1</str>
>> > <str>B2</str>
>> > <str>B3</str>
>> > </arr>
>> > </doc>
>> > <doc>
>> > <arr name="ad_text">
>> > <str>B3</str>
>> > <str>B2</str>
>> > <str>B1</str>
>> > </arr>
>> > </doc>
>>

Re: query help

Posted by Ahmet Arslan <io...@yahoo.com>.
> b) As i have explained i have result set( documents ) and
> each document
> contains a fields "*ad_text*" (with other fields also) which
> is
> multivalued..storing some tags say "B1, B2, B3" in each. bt
> order of tags
> are different for each doc. say (B1, B2, B3) *for
> doc1*,  B3,B1 B2*, for
> doc2*, B1, B3, B2*, doc3*, B2, B3, B1* for doc4*
> 
> if i search for B1: result should come in following order:
> doc1,doc3,doc2,doc4
> (As B1 is first value in maltivalued result for doc1and
> doc3, and B1 is in
> 2nd value in doc2 while  B1 is at 3rd in doc4  )
> if i search for B2: result should come in following order:
> doc4
> ,doc1,doc3,doc2


I have an idea that could work. Please note that this is untested.

Insert an artificial token at index time. e.g. your multivalued field becomes from "B1, B2, B3" to "ARTIFICIALTOKEN, B1, B2, B3"

And fire a query like &q=multivaluedField:"ARTIFICIALTOKEN B2"~1000000^10

Sort by relevancy score (which is the default) should do the trick.

"It may be desirable to boost the score of documents with query terms that appear closer together.... Phrase queries with slop will score higher when the terms are closer together." 

http://wiki.apache.org/solr/SolrRelevancyCookbook#Term_Proximity


Re: query help

Posted by Abhishek tiwari <ab...@gmail.com>.
a) No. i do not want to sort the content within document .
I want to sort the documents .
b) As i have explained i have result set( documents ) and each document
contains a fields "*ad_text*" (with other fields also) which is
multivalued..storing some tags say "B1, B2, B3" in each. bt order of tags
are different for each doc. say (B1, B2, B3) *for doc1*,  B3,B1 B2*, for
doc2*, B1, B3, B2*, doc3*, B2, B3, B1* for doc4*

if i search for B1: result should come in following order:
doc1,doc3,doc2,doc4
(As B1 is first value in maltivalued result for doc1and doc3, and B1 is in
2nd value in doc2 while  B1 is at 3rd in doc4  )
if i search for B2: result should come in following order: doc4
,doc1,doc3,doc2


I donot know whether it is possible or not ..

but please suggest how it can be done.



On Thu, Mar 29, 2012 at 5:18 PM, Erick Erickson <er...@gmail.com>wrote:

> Hmmm, I don't quite get this. Are you saying that you want
> to sort the documents or sort the content within the document?
>
> Sorting documents (i.e the results list) requires a single-valued
> field. So you'd have to, at index time, sort the entries.
>
> Sorting the content within the document is something you'd
> have to do when you index, Solr doesn't rearrange the
> contents of a document.
>
> If all you want to do is display the results within the document
> in order, your app can do that as it builds the display page.
>
> Best
> Erick
>
> On Wed, Mar 28, 2012 at 9:02 AM, Abhishek tiwari
> <ab...@gmail.com> wrote:
> > Hi ,
> > i have multi valued field want to sort the docs order the particular
> > text eq:'B1' is added.
> > how i should query? ad_text is multivalued field.
> >
> > t
> >
> > <doc>
> > <arr name="ad_text">
> > <str>B1</str>
> > <str>B2</str>
> > <str>B3</str>
> > </arr>
> > </doc>
> > <doc>
> > <arr name="ad_text">
> > <str>B2</str>
> > <str>B1</str>
> > <str>B3</str>
> > </arr>
> > </doc>
> >
> > <doc>
> > <arr name="ad_text">
> > <str>B1</str>
> > <str>B2</str>
> > <str>B3</str>
> > </arr>
> > </doc>
> > <doc>
> > <arr name="ad_text">
> > <str>B3</str>
> > <str>B2</str>
> > <str>B1</str>
> > </arr>
> > </doc>
>

Re: query help

Posted by Erick Erickson <er...@gmail.com>.
Hmmm, I don't quite get this. Are you saying that you want
to sort the documents or sort the content within the document?

Sorting documents (i.e the results list) requires a single-valued
field. So you'd have to, at index time, sort the entries.

Sorting the content within the document is something you'd
have to do when you index, Solr doesn't rearrange the
contents of a document.

If all you want to do is display the results within the document
in order, your app can do that as it builds the display page.

Best
Erick

On Wed, Mar 28, 2012 at 9:02 AM, Abhishek tiwari
<ab...@gmail.com> wrote:
> Hi ,
> i have multi valued field want to sort the docs order the particular
> text eq:'B1' is added.
> how i should query? ad_text is multivalued field.
>
> t
>
> <doc>
> <arr name="ad_text">
> <str>B1</str>
> <str>B2</str>
> <str>B3</str>
> </arr>
> </doc>
> <doc>
> <arr name="ad_text">
> <str>B2</str>
> <str>B1</str>
> <str>B3</str>
> </arr>
> </doc>
>
> <doc>
> <arr name="ad_text">
> <str>B1</str>
> <str>B2</str>
> <str>B3</str>
> </arr>
> </doc>
> <doc>
> <arr name="ad_text">
> <str>B3</str>
> <str>B2</str>
> <str>B1</str>
> </arr>
> </doc>