[英]How to Sort Solr field in case insensitive manner
I want to Sort string fields in Solr as case insensitive manner.我想以不区分大小写的方式对 Solr 中的字符串字段进行排序。
The search results are displayed as oracle sort manner, ie it first takes any special characters, numbers, upper case (AZ) then lower case (az).搜索结果显示为oracle排序方式,即先取任何特殊字符、数字、大写(AZ)再小写(az)。
The results should be special characters, numbers, upper case (A), lowercase (a) – through uppercase (Z) lowercase(z)结果应为特殊字符、数字、大写 (A)、小写 (a) – 到大写 (Z) 小写 (z)
Current Expected
110000 110000
ATest ATest
Btest aTest
Ctest BTest
Ztest bTest
aTest CTest
bTest cTest
cTest ZTest
Please help in configuring string field to Sort in Expected manner.请帮助配置字符串字段以按预期方式排序。
One way to achieve this would be for you to store the lower-case version of the text in a separate Solr string field when you ingest the data (eg code_for_sorting_s
) and then sort by that field.实现此目的的一种方法是,当您提取数据(例如code_for_sorting_s
)时,将文本的小写版本存储在单独的 Solr 字符串字段中,然后按该字段排序。
Another way to get there would be to define a copy-field
in Solr that automatically copies the value in your current field (eg code_s
) to a new field that uses the Lower Case Filter .另一种方法是在 Solr 中定义一个copy-field
,该字段会自动将当前字段(例如code_s
)中的值复制到使用小写过滤器的新字段中。 Using the built-in types in Solr your copy-field
definition could look more or less like this:使用 Solr 中的内置类型,您的copy-field
定义可能或多或少如下所示:
curl -X POST -H 'Content-type:application/json' --data-binary '{
"add-copy-field":{
"source":"code_s",
"dest":[ "code_s_lower" ]}
}' http://your-solr-core-url/schema
In this case the value of the code_s
field will be copied to a new field ( code_s_lower
).在这种情况下, code_s
字段的值将被复制到一个新字段 ( code_s_lower
)。 The *_s_lower
suffix is defined in Solr to create a string field that uses the Lower Case Filter that I alluded to. *_s_lower
后缀在 Solr 中定义,以创建一个使用我提到的小写过滤器的字符串字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.