tags:

views:

40

answers:

1

Hi I have document with fields like (title, content, datetime) I want to sort the results with the following formula

1) title boosts 2.5

2) content boost 1.5

3) IMPORTANT (boost those documents that is newer means datetime field is near today date) boost 3

how can I write a query considering the above criteria what should I do for #3

any help would be greatly appreciate.

+1  A: 
+title:foo^2.5 +content:bar^1.5 datetime:20100721^3

Obviously, fill in appropriate values for the datetime field. The key here is that the datetime term is not a required term; it only functions increase the score for documents that match the term. You can add another datetime term for yesterday's date, and another for the day before, and so on, while decreasing the boost as you get farther away from today's date.

bajafresh4life
This is completely unrelated to my question. I don't want to search for datetime I just want to score those documents that is rear to the current date, and i think it is a kind of scoring or sorting but i don't know how can i implement it
Ehsan
Baja's answer is actually the right one, although lucene's syntax is a bit non-intuitive. basically, you want: "+(original query) scoreBoostQuery" This will only match things which match "original query". But it will have a boost for things which also match scoreBoostQuery.
Xodarap