Opensearchsever -Search range beteen dates- JSON Restful API

649 views Asked by At

I'm trying to use OpenSearchServer in one of my applications using RestFul JSON API .Can you please provide an example for querying search between 2 dates using the restful JSON api?

Below is my code so far

{"query":"test help","rows":100, "returnedFields":[
"fileName", "url" ]
}

1

There are 1 answers

0
Krish On

Sorry for the bandwidth wastage.

To search between two dates using JSON API, we can use the "Relative date filter " . Here's what the documentation says : The Relative date filter can be used for this. Let's say that documents are indexed with the current date in the field indexedDate. In our example the date is expressed using the yyyyMMddHHmmss format - for instance 20141225130512 stands for the 25th of December, 2014, at 1:05:12 PM. eg: "filters":[
{
"negative":false, "type":"RelativeDateFilter", "from":{
"unit":"days", "interval":2 }, "to":{
"unit":"days", "interval":0 }, "field":"indexedDate", "dateFormat":"yyyyMMddHHmmss" } ],

Further details can be found here :http://www.opensearchserver.com/documentation/faq/querying/how_to_use_filters_on_query.md