If I understand correctly, you want exact matches on the username field to
be ranked higher than partial matches on username or matches on any other
What about indexing username twice, using two different tokenizers? One
that splits on whitespace and one that does not. Then if you want to boost
exact matches on username you can use a DisMaxQuery to give a higher boost
when the username is an exact match.
This example can be extended/modified if you want to boost prefix matches
(e.g., by using PrefixQuery or SpanFirstQuery rather than MatchQuery).
Ultimately, I think you'll need to leverage DisMaxQuery.
On Thursday, January 17, 2013 5:24:37 AM UTC-5, Sara wrote:
Started to work on elasticsearch recently and it has been an interesting
couple of months.
I have Indexed few documents in elasticsearch. Each document has got
fields like username, biography, post, interests etc. I want to do a text
search for 'Smith' in all the indexed fields with the field 'username'
starting with Smith ranking higher than the partial match on the 'username'
field and on other fields like post, interests etc.
I am using grails and I have given higher boost for username but I want
the document with username 'Smith' ranked higher than the document with
username 'Joe Smith' or other fields having prefix or partial matches. How
do i approach this issue? Thanks.