0

I have a search field "title", within it, I want to say "things that match nearer the start of the title should be scored higher in the search results".

e.g.

Title: "The quick brown fox jumps over the lazy dog"
Title: "the lazy dogs were under the jumping quick brown fox"
Title: "The lazy brown fox jumps over the quick dog"
Title: "The brown fox made quick jumps over the sleazy dog"

if I search for "quick", I want the first result to be ranked top, and the 4th result to be ranked 2nd.

Is this possible within lucene? I'm using Lucene.NET / Version_29 if it makes any difference.

tenshi_a
  • 181
  • 2
  • 10

1 Answers1

0

During indexing, along with every term, you can store the position of it's first occurrence in the payload of the corresponding term. During retrieval, you can work with a modified similarity function where you could take into consideration the stored position of a term in addition to the term weights.

A related SO question is here

Community
  • 1
  • 1
Debasis
  • 3,680
  • 1
  • 20
  • 23