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 Kurt Sultana <ku...@gmail.com> on 2011/06/01 10:21:03 UTC

Query problem in Solr

 Hi all,

We're using Solr to search on a Shop index and a Product index. Currently a
Shop has a field `shop_keyword` which also contains the keywords of the
products assigned to it. The shop keywords are separated by a space.
Consequently, if there is a product which has a keyword "apple" and another
which has "orange", a search for shops having `Apple AND Orange` would
return the shop for these products.

However, this is incorrect since we want that a search for shops having
`Apple AND Orange` returns shop(s) having products with both "apple" and
"orange" as keywords.

We tried solving this problem, by making shop keywords multi-valued and
assigning the keywords of every product of the shop as a new value in shop
keywords. However as was confirmed in another post
http://markmail.org/thread/xce4qyzs5367yplo#query:+page:1+mid:76eerw5yqev2aanu+state:results,
Solr does not support "all words must match in the same value of a
multi-valued field".

(Hope I explained myself well)

How can we go about this? Ideally, we shouldn't change our search
infrastructure dramatically.

Thanks!

Krt_Malta

Re: Query problem in Solr

Posted by pravesh <su...@yahoo.com>.
>>We're using Solr to search on a Shop index and a Product index
Do you have 2 separate indexes (using distributed shard search)?? I'm sure
you are actually having only single index.


>> Currently a Shop has a field `shop_keyword` which also contains the
>> keywords of the products assigned to it.

You mean, for a shop, you are first concatenating all keywords of all
products and then saving in shop_keywords field for the shop?? In this case
there is no way u can identify which keyword occurs in which product in ur
index.
You might need to change the index structure, may be, when u post documents,
then post a single document for a single product(with fields like
title,price,shop-id, etc), instead of single document for a single shop.
Hope I make myself clear

--
View this message in context: http://lucene.472066.n3.nabble.com/Query-problem-in-Solr-tp3009812p3010072.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Query problem in Solr

Posted by Kurt Sultana <ku...@gmail.com>.
@ Pravesh: It's 2 seperate cores, not 2 indexes. Sorry for that.

@ Erick: Yes, I've seen this suggestion and it seems to be the only possible
solution. I'll look into it.

Thanks for your answers guys!
Kurt

On Wed, Jun 1, 2011 at 4:24 PM, Erick Erickson <er...@gmail.com>wrote:

> If I read this correctly, one approach is to specify an
> increment gap in a multiValued field, then search for phrases
> with a slop less than that increment gap. i.e.
> incrementGap=100 in your definition, and search for
> "apple orange"~99
>
> If this is gibberish, please post some examples and we'll
> try something else.
>
> Best
> Erick
>
> On Wed, Jun 1, 2011 at 4:21 AM, Kurt Sultana <ku...@gmail.com>
> wrote:
> >  Hi all,
> >
> > We're using Solr to search on a Shop index and a Product index. Currently
> a
> > Shop has a field `shop_keyword` which also contains the keywords of the
> > products assigned to it. The shop keywords are separated by a space.
> > Consequently, if there is a product which has a keyword "apple" and
> another
> > which has "orange", a search for shops having `Apple AND Orange` would
> > return the shop for these products.
> >
> > However, this is incorrect since we want that a search for shops having
> > `Apple AND Orange` returns shop(s) having products with both "apple" and
> > "orange" as keywords.
> >
> > We tried solving this problem, by making shop keywords multi-valued and
> > assigning the keywords of every product of the shop as a new value in
> shop
> > keywords. However as was confirmed in another post
> >
> http://markmail.org/thread/xce4qyzs5367yplo#query:+page:1+mid:76eerw5yqev2aanu+state:results
> ,
> > Solr does not support "all words must match in the same value of a
> > multi-valued field".
> >
> > (Hope I explained myself well)
> >
> > How can we go about this? Ideally, we shouldn't change our search
> > infrastructure dramatically.
> >
> > Thanks!
> >
> > Krt_Malta
> >
>

Re: Query problem in Solr

Posted by Erick Erickson <er...@gmail.com>.
If I read this correctly, one approach is to specify an
increment gap in a multiValued field, then search for phrases
with a slop less than that increment gap. i.e.
incrementGap=100 in your definition, and search for
"apple orange"~99

If this is gibberish, please post some examples and we'll
try something else.

Best
Erick

On Wed, Jun 1, 2011 at 4:21 AM, Kurt Sultana <ku...@gmail.com> wrote:
>  Hi all,
>
> We're using Solr to search on a Shop index and a Product index. Currently a
> Shop has a field `shop_keyword` which also contains the keywords of the
> products assigned to it. The shop keywords are separated by a space.
> Consequently, if there is a product which has a keyword "apple" and another
> which has "orange", a search for shops having `Apple AND Orange` would
> return the shop for these products.
>
> However, this is incorrect since we want that a search for shops having
> `Apple AND Orange` returns shop(s) having products with both "apple" and
> "orange" as keywords.
>
> We tried solving this problem, by making shop keywords multi-valued and
> assigning the keywords of every product of the shop as a new value in shop
> keywords. However as was confirmed in another post
> http://markmail.org/thread/xce4qyzs5367yplo#query:+page:1+mid:76eerw5yqev2aanu+state:results,
> Solr does not support "all words must match in the same value of a
> multi-valued field".
>
> (Hope I explained myself well)
>
> How can we go about this? Ideally, we shouldn't change our search
> infrastructure dramatically.
>
> Thanks!
>
> Krt_Malta
>