Calling up the latest content in lucene search results

I store various articles in my lucene index. When a user searches for articles containing a specific term or phrase, I need to show all articles (maybe anywhere between 1000 and 10,000 articles), but with new articles "bubbled" in the search results.

I believe you can increase your search results in Lucene using "Boosting Field Field". Can someone please give me details on how to do this?

Thanks in advance!

+1


source to share


2 answers


I would follow the SortComparatorSource interface . You have to write a new ScoreDocComparator , the compare () function compares the two dates. Then you need to sort your search using the new sorter. This tip is taken from Chapter 6 of Lucene in Action .



+3


source


You can use the setBoost method to set promotions for a specific document in the index at index time. Since boost is 1.0 by default, setting the value less than 1.0 will make the document "less relevant" in search results. By linking to an incremental value of a document to its age (lower as the document gets older), you can make more recent content more relevant in search results.



Note that in the documentation for setBoost

, the boost value set during indexing is not available for retrieved documents (speedup works, you simply cannot read the value back during search to see if you applied the correct value at index time).

+1


source







All Articles