Solr fields sorting 排序相关(Integers, Longs, Floats, or String and multi-language 多语言相关)

Solr 如何解析query url中的sort参数,可见以下代码的调用顺序(https://github.com/scholarslab/SolrSearch/issues/25):

org.apache.solr.core.SolrCore - org.apache.solr.common.SolrException: can not sort on multivalued field: 40_s
at org.apache.solr.schema.SchemaField.checkSortability(SchemaField.java:161)
at org.apache.solr.schema.FieldType.getStringSort(FieldType.java:527)
at org.apache.solr.schema.StrField.getSortField(StrField.java:40)
at org.apache.solr.schema.SchemaField.getSortField(SchemaField.java:144)
at org.apache.solr.search.QueryParsing.parseSort(QueryParsing.java:385)
at org.apache.solr.search.QParser.getSort(QParser.java:251)
at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:102)
at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:173)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1372)
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:356)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:252)


QueryParsing.parseSort 最终返回 org.apache.lucene.search.Sort 对象:

http://grepcode.com/file/repo1.maven.org/maven2/org.apache.lucene/lucene-core/4.2.0/org/apache/lucene/search/Sort.java#Sort

其中对String类型的排序顺序默认是natural order,也就是The comparison is based on the Unicode value of each character in the strings. 


那么,如何处理多语言情况下的String排序呢?参见

http://wiki.apache.org/solr/UnicodeCollation

http://solr.pl/en/2011/04/11/car-sale-application-%E2%80%93-unicode-collation-sorting-text-in-a-language-sensitive-way-part-4/

http://docs.oracle.com/javase/7/docs/api/java/text/Collator.html

你可能感兴趣的:(Search)