What would be the best way to implement a custom range filter using Solr?

StackOverflow https://stackoverflow.com/questions/18546042

  •  26-06-2022
  •  | 
  •  

Вопрос

What would be the best way to implement a custom range filter using Solr? I.e. I want to show a filter "Harddrive" (for PC's), which can have a value in the range from 32GB to 2TB. I want these values to be added to the query to Solr as a range-facet.

What will be the solr query?

Это было полезно?

Решение

Assuming you've indexed your document with key="size" and the value is in megabytes and you want to query the range 32GB to 2TB:

    http://[solrnet:8080]/solr/search?q=size:[32000 TO 2000000]

In other words: you need to translate 32GB and 2TB to the appropriate number of megabytes yourself, before constructing the query.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top