Time for action – playing with range queries

Another good option for queries is the possibility to play over a certain range of data. This is particularly useful when dealing with numeric values (the trie types are designed to perform well in this case) and date/timestamp values too.

Just to give you an idea, we could test the following simple queries:

>> curl -X GET 'http://localhost:8983/solr/paintings_readonly/select?q=width:[5 TO 8]&fl=title'
>> curl -X GET 'http://localhost:8983/solr/paintings_readonly/select?q=timestamp:[* TO NOW]'
>> curl -X GET 'http://localhost:8983/solr/paintings_readonly/select?q=timestamp:[NOW-20MINUTES TO NOW}'

What just happened?

The first case is really intuitive. In it, we search for documents with width values from five to eight.

For dates, on the other hand, things generally get a bit more complicated. Solr uses the default canonical representation for date types as given in the following link:

http://www.w3.org/TR/xmlschema-2/#dateTime-canonical-representation

We can use some modifiers to handle a relative period of time. In the third example, we search from 20 minutes ago to now. Notice that although the square bracket represents included values, the curly brackets represent values that are not to be included.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.103.210