2012-11-14 38 views
6

我正在使用Solr 3.6.1。什么是正确的字段类型用于包含整数值的Solr排序字段?我只需要这个字段进行排序,并且不会对它进行范围查询。我应该使用integer还是sint什么是正确的Solr fieldType用于排序整数值?

我看到,在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"/> 

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"/> 

我问这种情况的主要原因是因为每次的Solr排序我做的sint字段(我有很多他们声明为动态字段)填充(不可配置)lucene fieldCache。我看到的统计数据页上sint各种存储为

org.apache.lucene.search.FieldCache$StringIndex

integer各种存储为

(HTTP:PORT/Solr的/ CORE /管理/ stats.jsp:// HOST)fieldCache下

org.apache.lucene.search.FieldCache.DEFAULT_INT_PARSER

我相信哪些消耗空间更少?


UPDATE:Solr的3.6.1 schema.xml中已宣布int作为TrieIntField即作为

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

该一个以上是从旧版本的solr。

+3

您应该始终使用TrieIntField而不是IntField和SortableIntField:此类具有**多** **多内存效率的FieldCache impl – jpountz

回答

7

如果您不需要范围查询,使用 “整数” 作为Sorts work correctly on both

Documentation: -

可排序域类型像烧结靶,sdouble是有点用词不当。在上述意义上,它们不需要排序,但在执行RangeQuery查询时需要 。实际上,Sortables参考 这个概念,使得按字典顺序将数字排序为 字符串。也就是说,如果没有这样做,数字1..10将 按字典顺序排列为1,10,2,3 ...使用sint,但是补救措施 这个。但是,如果您不需要执行RangeQuery查询,并且只有 需要在该字段上进行排序,则只需使用int或double或 等效适当的类。你将节省自己的时间和记忆。

1

可排序字段类型在Solr 5中被弃用,不应使用。您可以使用solr int或tint字段类型

相关问题