在solr中搜索范围内的数字

searching for number in a range in solr

我在 solr 中的一个字段是 "score",它是一个介于 0 和 1 之间的十进制数。

如何 return 特定分数范围内的所有数据?

例如return 得分在 0.1-0.2

范围内的所有文档

A legacy numeric field type that encodes "Float" values as simple Strings. This class should not be used except by people with existing indexes that contain numeric values indexed as Strings. New schemas should use TrieFloatField. Field values will sort numerically, but Range Queries (and other features that rely on numeric ranges) will not work as expected: values will be evaluated in unicode String order, not numeric order.

float field

为您的字段使用以下字段类型。

<field name="score" type="tfloat" stored="true" indexed="true"/>

确保在更改架构后重新编制索引,然后尝试低于范围的查询。

&fq=score:[0.1 TO 0.2]