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 Daphna Chen-Deutsch <da...@comm-it.com> on 2011/08/08 16:47:26 UTC

matching exact/whole phrase

Hi,

I'm trying to search for a specific phrase on a specific index field.
The filed definition is : <field name="title_string" type="string" indexed="true" stored="true" />

Type definition:
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>

When trying the following query:
http://localhost:8983/solr/select?q=title_string:'One Shot'

I'm getting back titles that match the string 'One Shot' but also titles that only start with 'One Shot' (i.e. 'One Shot ABC')
In additional, the 'One Shot ABC' gets higher score then title that has exact match to 'One Shot'.

What should be the correct configuration so that the query will return only exact match?

Thanks




Re: matching exact/whole phrase

Posted by Erick Erickson <er...@gmail.com>.
Single quotes aren't part of the Lucene syntax. If you tack on
&debugQuery=on, you'll see something like this returned:

<str name="parsedquery">title_string:'One text:shot</str>

Note that the default field in my schema is "text", also note
the single quote that's part of " 'One" but not "shot".

Try with double quotes, that gets things through the parser
correctly. And your match with "One Shot ABC" is probably
matching because "shot" is in your default search field.

All in all, title_string has nothing to do with the results returned
I'd guess <G>...

Best
Erick

On Mon, Aug 8, 2011 at 10:47 AM, Daphna Chen-Deutsch
<da...@comm-it.com> wrote:
> Hi,
>
> I'm trying to search for a specific phrase on a specific index field.
> The filed definition is : <field name="title_string" type="string" indexed="true" stored="true" />
>
> Type definition:
> <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
>
> When trying the following query:
> http://localhost:8983/solr/select?q=title_string:'One Shot'
>
> I'm getting back titles that match the string 'One Shot' but also titles that only start with 'One Shot' (i.e. 'One Shot ABC')
> In additional, the 'One Shot ABC' gets higher score then title that has exact match to 'One Shot'.
>
> What should be the correct configuration so that the query will return only exact match?
>
> Thanks
>
>
>
>