是否可以查詢SOLR中有特殊字符的數字?Apache Solr - 查詢帶特殊字符的數字
我有一個字段score
它可以有小數百分比像35.49%
,104.18%
等
我需要查詢本場greater than
和less than
運營商。我曾嘗試使用WordDelimiterFilterFactory
並創建了一個像這樣的新自定義字段。
<fieldType name="alphaNumericSort" class="solr.TextField" sortMissingLast="false" omitNorms="true">
<analyzer>
<!-- KeywordTokenizer does no actual tokenizing, so the entire
input string is preserved as a single token
-->
<tokenizer class="solr.KeywordTokenizerFactory"/>
<!-- The LowerCase TokenFilter does what you expect, which can be
when you want your sorting to be case insensitive
-->
<filter class="solr.WordDelimiterFilterFactory"
generateWordParts="1"
generateNumberParts="1"
catenateWords="0"
catenateNumbers="0"
catenateAll="0"
preserveOriginal="1"
types="lang/delim-types.txt" />
<filter class="solr.LowerCaseFilterFactory" />
<!-- The TrimFilter removes any leading or trailing whitespace -->
<filter class="solr.TrimFilterFactory" />
<!-- Left-pad numbers with zeroes -->
<filter class="solr.PatternReplaceFilterFactory"
pattern="(\d+)" replacement="00000$1" replace="all"
/>
<!-- Left-trim zeroes to produce 6 digit numbers -->
<filter class="solr.PatternReplaceFilterFactory"
pattern="0*([0-9]{6,})" replacement="$1" replace="all"
/>
<!-- Remove all but alphanumeric characters -->
<filter class="solr.PatternReplaceFilterFactory"
pattern="([^a-z0-9])" replacement="" replace="all"
/>
</analyzer>
</fieldType>
文件DELIM-types.txt的內容是
%=> ALPHA
但是,當我這樣的查詢,
- score:[* TO 100.00]
一點也沒有不會返回任何結果。難道我做錯了什麼?
當你說「可以有」時 - 該領域還有什麼其他價值?與使用TextField相比,使用雙字段和處理字段將是最有效的,並且會給出正確的結果,在這種情況下,詞法排序會給您帶來不可思議的結果。 – MatsLindh
它只能有小數百分比;沒有其他的 – Deadfish