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 Ramzi Alqrainy <ra...@gmail.com> on 2012/08/27 15:18:00 UTC

Solr Partial and Exact Matching

I want to ask you about partial and exact matching. I have documents for
Places and we need to get exact match if the user search for place name and
get the results based on other factors (not place name) if the query is
general or partial.


This is an example to explain more details.
 
If we suppose that schema for our documents contains 2 fields like below.

<field name="Place Title" type="text" indexed="true" stored="true"
required="true"/>
<field name="Review" type="text" indexed="true" stored="true"
multiValued="true"/>

and we have 2 documents 

D1 :

Place Title : Pizza Hut
Review : Nice meal

D2 : 

Place Title : Little Caesar
Review :   Nice Pizza

If the user search for general query like pizza only, we will decrease the
rank for place title to support reviews like
&qf= place_title^1 review^2
But if we search about exact match like "Pizza Hut", we will increase the
rank
&qf= place_title^5 review^2

I have many idea like using term frequency and many approach but I need the
best practice for implenting it.

Please advice,
Thanks in advance.



--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Partial-and-Exact-Matching-tp4003478.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr Partial and Exact Matching

Posted by Jack Krupansky <ja...@basetechnology.com>.
You can also have a secondary text field which uses a specialized "stop" 
filter to remove the common terms.

-- Jack Krupansky

-----Original Message----- 
From: Ramzi Alqrainy
Sent: Monday, August 27, 2012 11:45 AM
To: solr-user@lucene.apache.org
Subject: Re: Solr Partial and Exact Matching

But I don't want to add these words as static because I can't restrict or
inclose all words, I need to play on weight only.



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Solr-Partial-and-Exact-Matching-tp4003478p4003508.html
Sent from the Solr - User mailing list archive at Nabble.com. 


Re: Solr Partial and Exact Matching

Posted by Ramzi Alqrainy <ra...@gmail.com>.
But I don't want to add these words as static because I can't restrict or
inclose all words, I need to play on weight only.



--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Partial-and-Exact-Matching-tp4003478p4003508.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr Partial and Exact Matching

Posted by Jack Krupansky <ja...@basetechnology.com>.
You could have a second keyword field with a regex filter to drop out common 
terms from restaurant names, such as "restaurant", "pizza", (even "hut"), 
etc.

-- Jack Krupansky

-----Original Message----- 
From: Ramzi Alqrainy
Sent: Monday, August 27, 2012 11:29 AM
To: solr-user@lucene.apache.org
Subject: Re: Solr Partial and Exact Matching

Many Thanks for your kind email. I expect that I have reached the 
information
in some other way. I will explain my point again with different scenario.

I have a big data of places. let's take sample of restaurants places under
category restaurants. Some of places contains "Restaurant" in their names
(e.g. "Jons Restaurant") and some doesn't (e.g. " Pizza Hut") .

When users search for "Restaurant", Actually they are not searching for a
certain restaurant. So, we need to remove the rank of place name, *why*? to
make sure that places which include "Restaurant" in their names don't affect
the ranking, and to support other factors like review, rating, category,
etc. , but when the users search for "Jons", they are actually searching for
"Jons Restaurant". So, in this case we will increase the weight for place
name to get it as first result. On other words we need to decrease place
name weight or rank if the query is common (idf is small) and increase it if
we search on query with big idf (rarely).

I hope you are understand my point of view.



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Solr-Partial-and-Exact-Matching-tp4003478p4003500.html
Sent from the Solr - User mailing list archive at Nabble.com. 


Re: Solr Partial and Exact Matching

Posted by Ramzi Alqrainy <ra...@gmail.com>.
Many Thanks for your kind email. I expect that I have reached the information
in some other way. I will explain my point again with different scenario.

I have a big data of places. let's take sample of restaurants places under
category restaurants. Some of places contains "Restaurant" in their names
(e.g. "Jons Restaurant") and some doesn't (e.g. " Pizza Hut") . 

When users search for "Restaurant", Actually they are not searching for a
certain restaurant. So, we need to remove the rank of place name, *why*? to
make sure that places which include "Restaurant" in their names don't affect
the ranking, and to support other factors like review, rating, category,
etc. , but when the users search for "Jons", they are actually searching for
"Jons Restaurant". So, in this case we will increase the weight for place
name to get it as first result. On other words we need to decrease place
name weight or rank if the query is common (idf is small) and increase it if
we search on query with big idf (rarely).

I hope you are understand my point of view.



--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Partial-and-Exact-Matching-tp4003478p4003500.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr Partial and Exact Matching

Posted by Jack Krupansky <ja...@basetechnology.com>.
You could index place name as both a text field and a separate keyword 
string field. The former would match on any word. The latter would match 
only on exact match (or wildcard) and could be boosted as you have indicated 
since it would be an exact match.

You can just do a copyField from one to the other. For the exact match 
field, use the KeywordTokenizerFactory plus a LowerCaseFilterFactory filter.

-- Jack Krupansky

-----Original Message----- 
From: Ramzi Alqrainy
Sent: Monday, August 27, 2012 9:37 AM
To: solr-user@lucene.apache.org
Subject: Re: Solr Partial and Exact Matching

Please allow me to add another document with another example.

D3 :

Place Title : Pizza Jons
Review : I love it.

When the user search for pizza [General Query] we need to decrease the rank
for place title and gets
Little Caesar
Pizza hut
Pizza Jons

When we search for Jons [Search For Name]
Pizza Jons

When we search for Pizza Hut [Exact Match]
Pizza Hut





--
View this message in context: 
http://lucene.472066.n3.nabble.com/Solr-Partial-and-Exact-Matching-tp4003478p4003489.html
Sent from the Solr - User mailing list archive at Nabble.com. 


Re: Solr Partial and Exact Matching

Posted by Ramzi Alqrainy <ra...@gmail.com>.
Please allow me to add another document with another example.

D3 :

Place Title : Pizza Jons
Review : I love it.

When the user search for pizza [General Query] we need to decrease the rank
for place title and gets
Little Caesar 
Pizza hut
Pizza Jons

When we search for Jons [Search For Name]
Pizza Jons

When we search for Pizza Hut [Exact Match]
Pizza Hut
 




--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Partial-and-Exact-Matching-tp4003478p4003489.html
Sent from the Solr - User mailing list archive at Nabble.com.