Hbase 二级索引 Solr int字段排序问题 can not sort on multivalued field

Hbase Solr 同步二级索引后,进行int字段排序时报错

报错如下

{
  "responseHeader":{
    "zkConnected":true,
    "status":400,
    "QTime":75,
    "params":{
      "q":"*:*",
      "sort":"hbase_indexer_fn_read_num desc",
      "_":"1576474856934"}},
  "error":{
    "metadata":[
      "error-class","org.apache.solr.common.SolrException",
      "root-error-class","org.apache.solr.common.SolrException"],
    "msg":"can not sort on multivalued field: hbase_indexer_fn_read_num",
    "code":400}}

提示不能是multivalued属性

多值在solr中显示如下,带中括号

false 情况下应为下图,不带中括号

修改 schema.xml 文件, multivalued = "false"

<field name="hbase_indexer_fn_read_num" type="string" indexed="true" multiValued="false" stored="true"/>

更新solr配置

更新配置文件;
solrctl instancedir --update vt_index /home/jast/opt/hbase-indexer/vt_weibo_index
更新collection;
solrctl collection --reload vt_index

再次写入数据,排序查询后还是提示异常,

原因:新版的solr,将默认的字段docValues="true"

扫描二维码关注公众号,回复: 8723463 查看本文章

最后加入 docValues="false"

<field name="hbase_indexer_fn_read_num" type="string" indexed="true" docValues="false" multiValued="false" stored="true"/>

再次查询,返回正常

docValues作用

docValues: 如果这个字段应该有文档值(doc values),设置为true。文档值在门
面搜索,分组,排序和函数查询中会非常有用。虽然不是必须的,而且会导致生成
索引变大变慢,但这样设置会使索引加载更快,更加NRT友好,更高的内存使用效率。
然而也有一些使用限制:目前仅支持StrField, UUIDField和所有 Trie*Fields,
并且依赖字段类型, 可能要求字段为单值(single-valued)的,必须的或者有默认值。

 参考链接:https://www.jianshu.com/p/2f4a2f77eaad

发布了131 篇原创文章 · 获赞 33 · 访问量 66万+

猜你喜欢

转载自blog.csdn.net/zhangshenghang/article/details/103566484