简体   繁体   English

如何以不区分大小写的方式对 Solr 字段进行排序

[英]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.

相关问题 PagingAndSortingRepository 如何排序不区分大小写? - PagingAndSortingRepository how to sort case insensitive? 配置Solr对值执行不区分大小写的排序 - Configure Solr to perform case-insensitive sort on values 以不区分大小写的方式对来自Android SDK游标的managedQuery的结果进行排序 - Sort results from an Android sdk Cursor's managedQuery in a case insensitive manner 排序向量的wstrings,但不区分大小写 - Sort a vector of wstrings, but case insensitive Middleman标签排序不区分大小写 - Middleman tag sort case insensitive 如何使用Spring Data Rest对不区分大小写的数据进行排序? - How can I Sort data Case insensitive with Spring Data Rest? 不区分大小写的排序在 Swift 或其他语言中如何工作? - How does case insensitive sort work in Swift or other languages? 如何使用 SQL Order By 语句对不区分大小写的结果进行排序? - How to use SQL Order By statement to sort results case insensitive? 如何使用 jQuery 对数据表 alphabitecal 和不区分大小写进行排序? - How to sort datatable alphabitecal and case insensitive using jQuery? 如何在 mongodb (3.4) 中实现不区分大小写的排序 - How to implement a case insensitive sort with aggregate in mongodb (3.4)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM