Quantcast

Boost recent documents

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Boost recent documents

Joaquin Cuenca Abela
Hi,

I want to be able to boost documents based on a datetime property, to
give more relevance to more recent documents. Is it possible to do it
in ElasticSearch?

Thanks!

--
Joaquin Cuenca Abela
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Boost recent documents

Clinton Gormley
On Tue, 2010-12-21 at 15:04 +0100, Joaquin Cuenca Abela wrote:
> Hi,
>
> I want to be able to boost documents based on a datetime property, to
> give more relevance to more recent documents. Is it possible to do it
> in ElasticSearch?

yes - here's an example (you could do it with scripts as well)

curl -XGET 'http://127.0.0.1:9200/_all/_search'  -d '
{
   "query" : {
      "bool" : {
         "must" : {
            "field" : {
               "_all" : "foo bar baz"
            }
         },
         "should" : [
            {
               "range" : {
                  "publish_date" : {
                     "boost" : 5,
                     "gte" : "2010-12-01 00:00:00"
                  }
               }
            },
            {
               "range" : {
                  "publish_date" : {
                     "lt" : "2010-12-01 00:00:00",
                     "boost" : 1
                  }
               }
            }
         ]
      }
   }
}
'

clint

Loading...