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 Daniel Mosesson <Da...@ipreo.com> on 2013/06/17 09:46:24 UTC
Different scores for exact and non-exact matching
What I am looking to do is take field that contains a string like (called name for example):
"This is a sample string"
and then query by that field so that a search for "This" gets x points (exact match), "sam" gets y points (partial match).
I attempted to do this via the sort and query parameters, like so:
sort=if(name==This,100,50) but this gives me an error:
sort param could not be parsed as a query, and is not a field that exists in the index: if(name==This,100,50)
Full URL:
http://localhost:8983/solr/db/select?q=name%3A*&sort=if(name%3D%3D%22This%22%2C100%2C50)+asc&fl=price%2Cname&wt=xml&indent=true
Is there a way to do this?
Note: I believe that I can at least get the documents that need to be sorted via (name:This AND name:This*) but then I do not know where to go from there (as I can't seem to get sort working for any functions).
Can anyone provide some examples for how to do this kind of thing?
Thank you.
________________________________
******************************************************************
This e-mail message and any attachments are confidential. Dissemination, distribution or copying of this e-mail or any attachments by anyone other than the intended recipient is prohibited. If you are not the intended recipient, please notify Ipreo immediately by replying to this e-mail, and destroy all copies of this e-mail and any attachments. Thank you!
******************************************************************
Re: Different scores for exact and non-exact matching
Posted by Otis Gospodnetic <ot...@gmail.com>.
Hi,
I think you are after indexing tokens with begin/end markers.
e.g.
"This is a sample string" becomes:
_This$
_is$
_a$
_sample$
_string$
+ (edge) ngrams of the above tokens
Then a query for /This string/ could become:
_This$^100 _string$^100 this string
(or something along those lines)
So this will match documents with "praying mantis" or "thisle" if
you've ngrammed the tokens during indexing, but docs with the proper
words "this" and "string" will be stronger matches because of the ^100
part.
Otis
--
Solr & ElasticSearch Support -- http://sematext.com/
On Mon, Jun 17, 2013 at 3:46 AM, Daniel Mosesson
<Da...@ipreo.com> wrote:
> What I am looking to do is take field that contains a string like (called name for example):
>
> "This is a sample string"
>
> and then query by that field so that a search for "This" gets x points (exact match), "sam" gets y points (partial match).
>
> I attempted to do this via the sort and query parameters, like so:
>
> sort=if(name==This,100,50) but this gives me an error:
> sort param could not be parsed as a query, and is not a field that exists in the index: if(name==This,100,50)
>
> Full URL:
> http://localhost:8983/solr/db/select?q=name%3A*&sort=if(name%3D%3D%22This%22%2C100%2C50)+asc&fl=price%2Cname&wt=xml&indent=true
>
> Is there a way to do this?
>
> Note: I believe that I can at least get the documents that need to be sorted via (name:This AND name:This*) but then I do not know where to go from there (as I can't seem to get sort working for any functions).
>
> Can anyone provide some examples for how to do this kind of thing?
>
> Thank you.
>
> ________________________________
>
> ******************************************************************
> This e-mail message and any attachments are confidential. Dissemination, distribution or copying of this e-mail or any attachments by anyone other than the intended recipient is prohibited. If you are not the intended recipient, please notify Ipreo immediately by replying to this e-mail, and destroy all copies of this e-mail and any attachments. Thank you!
> ******************************************************************
Re: Different scores for exact and non-exact matching
Posted by Upayavira <uv...@odoko.co.uk>.
q="This is a sample string"^10 (This is a sample string)^5 fuzzy:(This
is a sample string)
You'd have to define the 'fuzzy' field as an EdgeNGram field, such that
'sample' gets indexed as:
s
sa
sam
samp
sampl
sample
Obviously, that'll take more space in your index, but I believe it would
get you the result you want.
Thus, exact phrase matches are boosted 10, docs that contain some of the
words are boosted 5, and fuzzy matches effectively get a boost of 1 (the
default).
Upayavira
On Mon, Jun 17, 2013, at 08:46 AM, Daniel Mosesson wrote:
> What I am looking to do is take field that contains a string like (called
> name for example):
>
> "This is a sample string"
>
> and then query by that field so that a search for "This" gets x points
> (exact match), "sam" gets y points (partial match).
>
> I attempted to do this via the sort and query parameters, like so:
>
> sort=if(name==This,100,50) but this gives me an error:
> sort param could not be parsed as a query, and is not a field that exists
> in the index: if(name==This,100,50)
>
> Full URL:
> http://localhost:8983/solr/db/select?q=name%3A*&sort=if(name%3D%3D%22This%22%2C100%2C50)+asc&fl=price%2Cname&wt=xml&indent=true
>
> Is there a way to do this?
>
> Note: I believe that I can at least get the documents that need to be
> sorted via (name:This AND name:This*) but then I do not know where to go
> from there (as I can't seem to get sort working for any functions).
>
> Can anyone provide some examples for how to do this kind of thing?
>
> Thank you.
>
> ________________________________
>
> ******************************************************************
> This e-mail message and any attachments are confidential. Dissemination,
> distribution or copying of this e-mail or any attachments by anyone other
> than the intended recipient is prohibited. If you are not the intended
> recipient, please notify Ipreo immediately by replying to this e-mail,
> and destroy all copies of this e-mail and any attachments. Thank you!
> ******************************************************************