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 Shobhit <sh...@gmail.com> on 2014/10/07 17:55:00 UTC

Exact matches are not coming on Top for autocomplete search results.

Hi,
I am trying to get the exact search term coming at top in Solr search
results, but solr is not returning the exact matching records on top,
instead exact matching terms are coming somewhere down after few records.

For example :  
I am searching for term "New York World", and I want the New York World to
come on top of solr search results, but solr is returning results as ,

New York World Journal 
New York World Telegram
New York World

*Search query used : *

http://localhost:8981/typeahead/suggest/?q=new+york+world

*schema.xml *

<fieldType name="typeahead" class="solr.TextField">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.ISOLatin1AccentFilterFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EdgeNGramFilterFactory" maxGramSize="100"
minGramSize="1"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.ISOLatin1AccentFilterFactory"/>
<filter class="solr.PatternReplaceFilterFactory" pattern="^(.{20})(.*)?"
replacement="$1" replace="all"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
</fieldType>

<field name="name_something" type="typeahead" indexed="true" stored="false"
multiValued="true"/>

*solrconfig.xml*

requestHandler name="typeahead" class="solr.SearchHandler">
<lst name="defaults">
<str name="wt">json</str>
<int name="rows">10</int>
<str name="indent">true</str>
<str name="df">autosuggest</str>
<str name="q.op">AND</str>
<str name="fl">
name_s,pk_id,city_s,state_s,country_s
</requestHandler>

kindly provide your suggestions to achieve this.



--
View this message in context: http://lucene.472066.n3.nabble.com/Exact-matches-are-not-coming-on-Top-for-autocomplete-search-results-tp4163162.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Exact matches are not coming on Top for autocomplete search results.

Posted by Ahmet Arslan <io...@yahoo.com.INVALID>.
Hi Erick,

Yup you are correct. Sorry, I missed that all examples have that phrase.

Ahmet



On Wednesday, October 8, 2014 6:35 AM, Erick Erickson <er...@gmail.com> wrote:
bq: bq=typeahead:"New York World"^50 would do the trick.

I don't think so. All the examples have that phrase in them, so the
boost query would apply to all.

But Shobhit can do something similar with a copyField to a field that,
say, was a keyword tokenizer followed by a lower case filter and put a
very high boost on _that_ instead...

Best,
Erick


On Tue, Oct 7, 2014 at 12:22 PM, Ahmet Arslan <io...@yahoo.com.invalid> wrote:
> Hi,
>
> You can add an optional (phrase) clause to boost exact matches. If you are using (e)dismay
>
> bq=typeahead:"New York World"^50 would do the trick.
>
> Ahmet
>
>
>
> On Tuesday, October 7, 2014 6:55 PM, Shobhit <sh...@gmail.com> wrote:
> Hi,
> I am trying to get the exact search term coming at top in Solr search
> results, but solr is not returning the exact matching records on top,
> instead exact matching terms are coming somewhere down after few records.
>
> For example :
> I am searching for term "New York World", and I want the New York World to
> come on top of solr search results, but solr is returning results as ,
>
> New York World Journal
> New York World Telegram
> New York World
>
> *Search query used : *
>
> http://localhost:8981/typeahead/suggest/?q=new+york+world
>
> *schema.xml *
>
> <fieldType name="typeahead" class="solr.TextField">
> <analyzer type="index">
> <tokenizer class="solr.WhitespaceTokenizerFactory"/>
> <filter class="solr.LowerCaseFilterFactory"/>
> <filter class="solr.ISOLatin1AccentFilterFactory"/>
> <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
> ignoreCase="true" expand="true"/>
> <filter class="solr.LowerCaseFilterFactory"/>
> <filter class="solr.EdgeNGramFilterFactory" maxGramSize="100"
> minGramSize="1"/>
> <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
> </analyzer>
> <analyzer type="query">
> <tokenizer class="solr.KeywordTokenizerFactory"/>
> <filter class="solr.LowerCaseFilterFactory"/>
> <filter class="solr.ISOLatin1AccentFilterFactory"/>
> <filter class="solr.PatternReplaceFilterFactory" pattern="^(.{20})(.*)?"
> replacement="$1" replace="all"/>
> <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
> </analyzer>
> </fieldType>
>
> <field name="name_something" type="typeahead" indexed="true" stored="false"
> multiValued="true"/>
>
> *solrconfig.xml*
>
> requestHandler name="typeahead" class="solr.SearchHandler">
> <lst name="defaults">
> <str name="wt">json</str>
> <int name="rows">10</int>
> <str name="indent">true</str>
> <str name="df">autosuggest</str>
> <str name="q.op">AND</str>
> <str name="fl">
> name_s,pk_id,city_s,state_s,country_s
> </requestHandler>
>
> kindly provide your suggestions to achieve this.
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Exact-matches-are-not-coming-on-Top-for-autocomplete-search-results-tp4163162.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Exact matches are not coming on Top for autocomplete search results.

Posted by Erick Erickson <er...@gmail.com>.
bq: bq=typeahead:"New York World"^50 would do the trick.

I don't think so. All the examples have that phrase in them, so the
boost query would apply to all.

But Shobhit can do something similar with a copyField to a field that,
say, was a keyword tokenizer followed by a lower case filter and put a
very high boost on _that_ instead...

Best,
Erick

On Tue, Oct 7, 2014 at 12:22 PM, Ahmet Arslan <io...@yahoo.com.invalid> wrote:
> Hi,
>
> You can add an optional (phrase) clause to boost exact matches. If you are using (e)dismay
>
> bq=typeahead:"New York World"^50 would do the trick.
>
> Ahmet
>
>
>
> On Tuesday, October 7, 2014 6:55 PM, Shobhit <sh...@gmail.com> wrote:
> Hi,
> I am trying to get the exact search term coming at top in Solr search
> results, but solr is not returning the exact matching records on top,
> instead exact matching terms are coming somewhere down after few records.
>
> For example :
> I am searching for term "New York World", and I want the New York World to
> come on top of solr search results, but solr is returning results as ,
>
> New York World Journal
> New York World Telegram
> New York World
>
> *Search query used : *
>
> http://localhost:8981/typeahead/suggest/?q=new+york+world
>
> *schema.xml *
>
> <fieldType name="typeahead" class="solr.TextField">
> <analyzer type="index">
> <tokenizer class="solr.WhitespaceTokenizerFactory"/>
> <filter class="solr.LowerCaseFilterFactory"/>
> <filter class="solr.ISOLatin1AccentFilterFactory"/>
> <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
> ignoreCase="true" expand="true"/>
> <filter class="solr.LowerCaseFilterFactory"/>
> <filter class="solr.EdgeNGramFilterFactory" maxGramSize="100"
> minGramSize="1"/>
> <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
> </analyzer>
> <analyzer type="query">
> <tokenizer class="solr.KeywordTokenizerFactory"/>
> <filter class="solr.LowerCaseFilterFactory"/>
> <filter class="solr.ISOLatin1AccentFilterFactory"/>
> <filter class="solr.PatternReplaceFilterFactory" pattern="^(.{20})(.*)?"
> replacement="$1" replace="all"/>
> <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
> </analyzer>
> </fieldType>
>
> <field name="name_something" type="typeahead" indexed="true" stored="false"
> multiValued="true"/>
>
> *solrconfig.xml*
>
> requestHandler name="typeahead" class="solr.SearchHandler">
> <lst name="defaults">
> <str name="wt">json</str>
> <int name="rows">10</int>
> <str name="indent">true</str>
> <str name="df">autosuggest</str>
> <str name="q.op">AND</str>
> <str name="fl">
> name_s,pk_id,city_s,state_s,country_s
> </requestHandler>
>
> kindly provide your suggestions to achieve this.
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Exact-matches-are-not-coming-on-Top-for-autocomplete-search-results-tp4163162.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Exact matches are not coming on Top for autocomplete search results.

Posted by Ahmet Arslan <io...@yahoo.com.INVALID>.
Hi,

You can add an optional (phrase) clause to boost exact matches. If you are using (e)dismay

bq=typeahead:"New York World"^50 would do the trick.

Ahmet



On Tuesday, October 7, 2014 6:55 PM, Shobhit <sh...@gmail.com> wrote:
Hi,
I am trying to get the exact search term coming at top in Solr search
results, but solr is not returning the exact matching records on top,
instead exact matching terms are coming somewhere down after few records.

For example :  
I am searching for term "New York World", and I want the New York World to
come on top of solr search results, but solr is returning results as ,

New York World Journal 
New York World Telegram
New York World

*Search query used : *

http://localhost:8981/typeahead/suggest/?q=new+york+world

*schema.xml *

<fieldType name="typeahead" class="solr.TextField">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.ISOLatin1AccentFilterFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EdgeNGramFilterFactory" maxGramSize="100"
minGramSize="1"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.ISOLatin1AccentFilterFactory"/>
<filter class="solr.PatternReplaceFilterFactory" pattern="^(.{20})(.*)?"
replacement="$1" replace="all"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
</fieldType>

<field name="name_something" type="typeahead" indexed="true" stored="false"
multiValued="true"/>

*solrconfig.xml*

requestHandler name="typeahead" class="solr.SearchHandler">
<lst name="defaults">
<str name="wt">json</str>
<int name="rows">10</int>
<str name="indent">true</str>
<str name="df">autosuggest</str>
<str name="q.op">AND</str>
<str name="fl">
name_s,pk_id,city_s,state_s,country_s
</requestHandler>

kindly provide your suggestions to achieve this.



--
View this message in context: http://lucene.472066.n3.nabble.com/Exact-matches-are-not-coming-on-Top-for-autocomplete-search-results-tp4163162.html
Sent from the Solr - User mailing list archive at Nabble.com.