用于排序整数值的正确Solr fieldType是什么?

aru*_*run 6 sorting lucene solr

我正在使用Solr 3.6.1.用于包含整数值的Solr排序字段的正确字段类型是什么?我只需要将此字段用于排序,并且永远不会对其进行范围查询.我应该使用integersint

我在schema.xml中看到,sint类型声明为:

 <!-- Numeric field types that manipulate the value into
         a string value that isn't human-readable in its internal form,
         but with a lexicographic ordering the same as the numeric ordering,
         so that range queries work correctly. -->
    <fieldType name="sint" class="solr.SortableIntField" sortMissingLast="true" omitNorms="true"/>
Run Code Online (Sandbox Code Playgroud)

integer说如下:

 <!-- numeric field types that store and index the text
         value verbatim (and hence don't support range queries, since the
         lexicographic ordering isn't equal to the numeric ordering) -->
    <fieldType name="integer" class="solr.IntField" omitNorms="true"/>
Run Code Online (Sandbox Code Playgroud)

我问这个的主要原因是因为我在一个sint字段上做的每个Solr排序(我有很多声明为动态字段)填充(不可配置的)lucene fieldCache.我在fieldCache下的stats页面(http:// HOST:PORT/solr/CORE/admin/stats.jsp)上看到,sint排序存储为

org.apache.lucene.search.FieldCache$StringIndex

integer排序则存储为

org.apache.lucene.search.FieldCache.DEFAULT_INT_PARSER

我相信消耗更少的空间?


更新:Solr 3.6.1 schema.xml已int声明为TrieIntFieldie

<fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>

上面的一个是旧版的solr版本.

Jay*_*dra 7

如果您不需要范围查询,请使用"整数",因为 Sorts在两者上都能正常工作

文件: -

像sint,sdouble这样的可排序FieldType有点用词不当.在上述意义上,排序不需要它们,但在执行RangeQuery查询时需要它们.事实上,Sortables是指将数字按字典顺序排列为字符串的概念.也就是说,如果没有这样做,数字1..10按字典顺序排序为1,10,2,3 ......然而,使用sint可以解决这个问题.但是,如果您不需要执行RangeQuery查询并且只需要对字段进行排序,那么只需使用int或double或等效的适当类.你将节省自己的时间和记忆.