There is a title field, and I want to sort it by the first letter of Pinyin. There is a method in the solr method
params.setSort("title",ORDER.asc);//排序字段,正序还是倒序
But it seems that the result of this setting is not what I want. The result I want is as follows:
The first letter of the serial number title
1 aa
2 countryg
3 person r
4中z
In the SQL statement, I can sort by the first letter of Pinyin. I want to know if I can sort by the first letter of Pinyin in Solr? What should I do? Can I ask for guidance? ? ?
Can’t you just create a new field with the “first letter of title” as the value as a field? Generally speaking, in practical applications, custom fields are used as sorting conditions
There is a relatively simple method, as follows:
Result
You can also use pinyin4j for more complex sorting