我正在使用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
各種存儲爲
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。
您應該始終使用TrieIntField而不是IntField和SortableIntField:此類具有**多** **多內存效率的FieldCache impl – jpountz