Solr equivalent of SQL BETWEEN for numeric fields
Hoping for some pointers to speed up some (very) slow solr queries in version 3.4.0.
I have an index of about 6-million documents. Each document is quite small, and contains two solr.TrieDoubleField
s; "start" and "end".
<fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
----
<field name="start" type="double" indexed="true" stored="false" />
<field name="end" type="double" indexed="true" stored="false" />
When querying I need to perform the SQL equivalent of:
WHERE @input BETWEEN Start AND End
T开发者_StackOverflow社区o do this I'm writing my query as:
start:[* TO @input] AND end:[@input TO *]
The query succeeds, returning the correct document, but with a QTime of ~4,500; most other queries are well below 100.
What can be modified to improve performance?
I believe that you should try the Function Range (frange) query parser in Solr. Please see the introductory blog post - Ranges Over Functions in Solr 1.4 for more details on how to use the Function Range query parser. (Note this should apply to all versions of Solr greater that 1.4 as well)
So I think something like the following should work...
`?q=*:*&fq={!frange l=0 u=<@input>}start
&fq{!frange l=<@input> u=<number larger than greatest value>}end`
I am not sure if you can use wildcards for the upper and lower bounds, probably not...
精彩评论