按 attr_stream_size 对 solr 中的文档进行排序
Sort documents in solr by attr_stream_size
我在本地安装了solr-8.3.1。
使用文件示例,我使用 post-实用程序准备了一个 solr-core。
索引的查询非常快,现在我想使用搜索文件时返回的一些属性,这些属性似乎是在上传时创建的。
例如,我想按 attr_stream_size.
排序
有什么办法可以实现吗?
如果我直接在 solr-admin 的查询对话框中使用该字段:
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","org.apache.solr.common.SolrException"],
"msg":"can not sort on multivalued field: attr_stream_size of type: text_general",
"code":400}}
返回。
问题很清楚:
"can not sort on multivalued field: attr_stream_size of type: text_general"
您应该对其应用排序的字段必须是简单值的、非标记化的并且使用仅生成单个术语的分析器,或者将字段类型定义为 string而不是 text_general.
If you want to be able to sort on a field whose contents you want to
tokenize to facilitate searching, use a copyField directive in the
Schema to clone the field. Then search on the field and sort on its
clone.
例如,使用专门用于排序的适当字段类型(即字符串或数字字段或使用 KeywordTokenizer 或创建新字段的文本),例如使用 plong 字段类型:
<field name="size" type="plong" uninvertible="true" default="0" sortMissingLast="true" indexed="true" stored="true"/>
可排序字段可以由可搜索字段提供:
<copyField source="attr_stream_size" dest="size" />
以便您可以在搜索 attr_stream_size.
时按 大小 排序
我在本地安装了solr-8.3.1。
使用文件示例,我使用 post-实用程序准备了一个 solr-core。 索引的查询非常快,现在我想使用搜索文件时返回的一些属性,这些属性似乎是在上传时创建的。 例如,我想按 attr_stream_size.
排序有什么办法可以实现吗?
如果我直接在 solr-admin 的查询对话框中使用该字段:
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","org.apache.solr.common.SolrException"],
"msg":"can not sort on multivalued field: attr_stream_size of type: text_general",
"code":400}}
返回。
问题很清楚:
"can not sort on multivalued field: attr_stream_size of type: text_general"
您应该对其应用排序的字段必须是简单值的、非标记化的并且使用仅生成单个术语的分析器,或者将字段类型定义为 string而不是 text_general.
If you want to be able to sort on a field whose contents you want to tokenize to facilitate searching, use a copyField directive in the Schema to clone the field. Then search on the field and sort on its clone.
例如,使用专门用于排序的适当字段类型(即字符串或数字字段或使用 KeywordTokenizer 或创建新字段的文本),例如使用 plong 字段类型:
<field name="size" type="plong" uninvertible="true" default="0" sortMissingLast="true" indexed="true" stored="true"/>
可排序字段可以由可搜索字段提供:
<copyField source="attr_stream_size" dest="size" />
以便您可以在搜索 attr_stream_size.
时按 大小 排序