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/05/25 11:44:51 UTC

Returning documents using multi-valued field

Hi all,

I'm quite new to Solr and I'm supporting an existing Solr search engine
which was written by someone else. I've been reading on Solr for the last
couple of weeks so I'd consider myself beyond the basics.

A particular field, let's say name, is multi-valued. For example, a document
has a field "name" with values "Alice, Trudy". We want that the document is
returned when "Alice" or "Trudy" is input and not when "Alice Trudy" is
entered. Currently the document is even with "Alice Trudy". How could this
be done?

Thanks a lot!
Kurt

Re: Returning documents using multi-valued field

Posted by Kurt Sultana <ku...@gmail.com>.
Thanks for you answer James :)

For guys who would meet up with this problem,
http://markmail.org/thread/xce4qyzs5367yplo also speaks about this, and
reaches James' conclusion too.

On Thu, May 26, 2011 at 10:19 PM, Dyer, James <Ja...@ingrambook.com>wrote:

> This is a limitation of Lucene/Solr in that there is no way to tell it to
> not match across mutli-valued field occurences.
>
> A workaround is to convert your query to a phrase and add a "slop" factor
> less than your posititonIncrementGap.  ex:  q="alice trudy"~99  ... This
> example assumes that your positionIncrementGap is set to 100 (the default I
> think) or greater.  This tells it that rather than search for a strict
> phrase, the words in the phrase can be up to 99 positions apart.  Because
> the multi-valued fields are implemented under-the-covers by simply
> increasing the position of the next occurrence by the positionIncrementGap
> value, this will effectively prevent Lucene/Solr from matching across
> occurences.
>
> The downside to this workaround is that wildcards are not permitted in
> phrase searches.  So if you need wildcard support also, then you're out of
> luck.
>
> James Dyer
> E-Commerce Systems
> Ingram Content Group
> (615) 213-4311
>
>
> -----Original Message-----
> From: Kurt Sultana [mailto:kurtanatlus@gmail.com]
> Sent: Thursday, May 26, 2011 3:05 PM
> To: solr-user@lucene.apache.org
> Subject: Re: Returning documents using multi-valued field
>
> Hi, maybe I wasn't so clear in my previous post. Here's another go (I'd
> like
> a reply :) ):
>
> Currently I'm issuing this query on Solr:
>
> http://localhost:9001/solrfacetsearch/master_Shop/select/?q=%28keyword_text_mv%3A%28alice+AND+trudy%29%29+AND+%28catalogId%3A%22Default%22%29+AND+%28catalogVersion%3AOnline%29&start=0&rows=<http://localhost:9001/solrfacetsearch/master_Shop/select/?q=%28keyword_text_mv%3A%28alice+AND+trudy%29%29+AND+%28catalogId%3A%22Default%22%29+AND+%28catalogVersion%3AOnline%29&start=0&rows=2147483647&facet=true&facet.field=category_string_mv&sort=preferred_boolean+desc%2Cgeo_distance+asc&facet.mincount=1&facet.limit=50&facet.sort=index&radius=111.84681460272012&long=5.2864094&qt=geo&lat=52.2119418&debugQuery=on>
> 2147483647
> &facet=true&facet.field=category_string_mv&sort=preferred_boolean+desc%2Cgeo_distance+asc&facet.mincount=1&facet.limit=50&facet.sort=index&radius=111.84681460272012&long=5.2864094&qt=geo&lat=52.2119418&debugQuery=on
>
> where as you can see I'm searching for keywords Alice AND Trudy. This query
> returns a document which contains:
>
> <arr name="keyword_text_mv">
> <str>alice jill</str>
> <str>trudy alex</str>
> </arr>
>
> The problem is I'd like the document to be returned only if it contains a
> string "alice trudy" in one of its values, in other words, if it contains :
>
> <arr name="keyword_text_mv">
> <str>alice trudy</str>
> <str>jill alex</str>
> </arr>
>
> How could I achieve this? I'm supporting the code written by someone else
> and I'm quite new to Solr.
>
> Thanks in advance :)
>
> Kurt
>
>
> On Wed, May 25, 2011 at 11:44 AM, Kurt Sultana <kurtanatlus@gmail.com
> >wrote:
>
> >
> > Hi all,
> >
> > I'm quite new to Solr and I'm supporting an existing Solr search engine
> > which was written by someone else. I've been reading on Solr for the last
> > couple of weeks so I'd consider myself beyond the basics.
> >
> > A particular field, let's say name, is multi-valued. For example, a
> > document has a field "name" with values "Alice, Trudy". We want that the
> > document is returned when "Alice" or "Trudy" is input and not when "Alice
> > Trudy" is entered. Currently the document is even with "Alice Trudy". How
> > could this be done?
> >
> > Thanks a lot!
> > Kurt
> >
> >
>

RE: Returning documents using multi-valued field

Posted by "Dyer, James" <Ja...@ingrambook.com>.
This is a limitation of Lucene/Solr in that there is no way to tell it to not match across mutli-valued field occurences.

A workaround is to convert your query to a phrase and add a "slop" factor less than your posititonIncrementGap.  ex:  q="alice trudy"~99  ... This example assumes that your positionIncrementGap is set to 100 (the default I think) or greater.  This tells it that rather than search for a strict phrase, the words in the phrase can be up to 99 positions apart.  Because the multi-valued fields are implemented under-the-covers by simply increasing the position of the next occurrence by the positionIncrementGap value, this will effectively prevent Lucene/Solr from matching across occurences.  

The downside to this workaround is that wildcards are not permitted in phrase searches.  So if you need wildcard support also, then you're out of luck.

James Dyer
E-Commerce Systems
Ingram Content Group
(615) 213-4311


-----Original Message-----
From: Kurt Sultana [mailto:kurtanatlus@gmail.com] 
Sent: Thursday, May 26, 2011 3:05 PM
To: solr-user@lucene.apache.org
Subject: Re: Returning documents using multi-valued field

Hi, maybe I wasn't so clear in my previous post. Here's another go (I'd like
a reply :) ):

Currently I'm issuing this query on Solr:
http://localhost:9001/solrfacetsearch/master_Shop/select/?q=%28keyword_text_mv%3A%28alice+AND+trudy%29%29+AND+%28catalogId%3A%22Default%22%29+AND+%28catalogVersion%3AOnline%29&start=0&rows=2147483647&facet=true&facet.field=category_string_mv&sort=preferred_boolean+desc%2Cgeo_distance+asc&facet.mincount=1&facet.limit=50&facet.sort=index&radius=111.84681460272012&long=5.2864094&qt=geo&lat=52.2119418&debugQuery=on

where as you can see I'm searching for keywords Alice AND Trudy. This query
returns a document which contains:

<arr name="keyword_text_mv">
<str>alice jill</str>
<str>trudy alex</str>
</arr>

The problem is I'd like the document to be returned only if it contains a
string "alice trudy" in one of its values, in other words, if it contains :

<arr name="keyword_text_mv">
<str>alice trudy</str>
<str>jill alex</str>
</arr>

How could I achieve this? I'm supporting the code written by someone else
and I'm quite new to Solr.

Thanks in advance :)

Kurt


On Wed, May 25, 2011 at 11:44 AM, Kurt Sultana <ku...@gmail.com>wrote:

>
> Hi all,
>
> I'm quite new to Solr and I'm supporting an existing Solr search engine
> which was written by someone else. I've been reading on Solr for the last
> couple of weeks so I'd consider myself beyond the basics.
>
> A particular field, let's say name, is multi-valued. For example, a
> document has a field "name" with values "Alice, Trudy". We want that the
> document is returned when "Alice" or "Trudy" is input and not when "Alice
> Trudy" is entered. Currently the document is even with "Alice Trudy". How
> could this be done?
>
> Thanks a lot!
> Kurt
>
>

Re: Returning documents using multi-valued field

Posted by Kurt Sultana <ku...@gmail.com>.
Hi, maybe I wasn't so clear in my previous post. Here's another go (I'd like
a reply :) ):

Currently I'm issuing this query on Solr:
http://localhost:9001/solrfacetsearch/master_Shop/select/?q=%28keyword_text_mv%3A%28alice+AND+trudy%29%29+AND+%28catalogId%3A%22Default%22%29+AND+%28catalogVersion%3AOnline%29&start=0&rows=2147483647&facet=true&facet.field=category_string_mv&sort=preferred_boolean+desc%2Cgeo_distance+asc&facet.mincount=1&facet.limit=50&facet.sort=index&radius=111.84681460272012&long=5.2864094&qt=geo&lat=52.2119418&debugQuery=on

where as you can see I'm searching for keywords Alice AND Trudy. This query
returns a document which contains:

<arr name="keyword_text_mv">
<str>alice jill</str>
<str>trudy alex</str>
</arr>

The problem is I'd like the document to be returned only if it contains a
string "alice trudy" in one of its values, in other words, if it contains :

<arr name="keyword_text_mv">
<str>alice trudy</str>
<str>jill alex</str>
</arr>

How could I achieve this? I'm supporting the code written by someone else
and I'm quite new to Solr.

Thanks in advance :)

Kurt


On Wed, May 25, 2011 at 11:44 AM, Kurt Sultana <ku...@gmail.com>wrote:

>
> Hi all,
>
> I'm quite new to Solr and I'm supporting an existing Solr search engine
> which was written by someone else. I've been reading on Solr for the last
> couple of weeks so I'd consider myself beyond the basics.
>
> A particular field, let's say name, is multi-valued. For example, a
> document has a field "name" with values "Alice, Trudy". We want that the
> document is returned when "Alice" or "Trudy" is input and not when "Alice
> Trudy" is entered. Currently the document is even with "Alice Trudy". How
> could this be done?
>
> Thanks a lot!
> Kurt
>
>