gpt4 book ai didi

sorting - 用于对整数值进行排序的正确 Solr 字段类型是什么?

转载 作者:行者123 更新时间:2023-12-02 21:13:37 25 4
gpt4 key购买 nike

我正在使用 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"/>

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

我问这个的主要原因是因为我在 sint 上所做的每一次 Solr 排序字段(我有很多声明为动态字段)填充(不可配置的)lucene fieldCache。我在 fieldCache 下的统计页面 (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声明为TrieIntField即作为

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

上面的来自旧的 solr 版本。

最佳答案

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

Documentation :-

Sortable FieldTypes like sint, sdouble are a bit of a misnomer. They are not needed for Sorting in the sense described above, but are needed when doing RangeQuery queries. Sortables, in fact, refer to the notion of making the number sort correctly lexicographically as Strings. That is, if this is not done, the numbers 1..10 sort lexicographically as 1,10, 2, 3... Using an sint, however remedies this. If, however, you don't need to do RangeQuery queries and only need to sort on the field, then just use an int or double or the equivalent appropriate class. You will save yourself time and memory.

关于sorting - 用于对整数值进行排序的正确 Solr 字段类型是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13372323/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com