在Solr中的文本字段上排序 [英] Sorting on text field in solr

查看:152
本文介绍了在Solr中的文本字段上排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用solr 3.4,并希望在文本字段中对solr搜索结果进行排序.如何像使用自然排序一样在文本字段上实现排序?

I am using solr 3.4 and want to have solr search results to be sorted on text field. How can I achieve sorting on text field as with int natural ordering?

在查询过程中是否可以将文本字段转换为int?

Is there any way to convert text field to int during query?

我的排序字段是字符串类型,我希望它在排序时表现为int字段.我无法更改字段类型,因为索引大小太大并且无法重新索引.

My sort field is of string type and I want it to be behave as int field while sorting. I can not change field type as the index size is too large and can not re index.

任何想法我该如何实现?

Any idea how can I achieve this?

推荐答案

不太确定,但是您可以检查

Not very sure, but you can check for the Function Queries with functions like abs or any mathematical functions which might convert it to the int values and use it for sort

例如abs(some_field) desc

否则,将字段复制到需要重新索引的int类型的新字段中.

Else, copy the field into the new field with int type which would need reindex.

此外,排序在多值和标记化文本字段上的效果也不佳.

Also, Sorting doesn't work good on multivalued and tokenized Text fields.

文档- 排序可以在文档的分数"上进行,也可以在任何multiValued ="false" indexed ="true"字段上进行,前提是该字段是未标记的(即:没有分析器)或使用仅产生单个字词(即:使用KeywordTokenizer)

Documentation - Sorting can be done on the "score" of the document, or on any multiValued="false" indexed="true" field provided that field is either non-tokenized (ie: has no Analyzer) or uses an Analyzer that only produces a single Term (ie: uses the KeywordTokenizer)

这篇关于在Solr中的文本字段上排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆