![](/img/trans.png)
[英]How to sort from highest to lowest occurence from within a multivalued attribute using SQL?
[英]How to sort Solr Multivalued Result Or Store data without multivalued
我想按sku排序solr結果,
這是我對結果進行排序的查詢
http://localhost:8983/solr/test_core/select?sort=skucode+asc&q=*skucode*&wt=xml
skucode標記將數據存儲在數字字段中。
<str name="id">39902395</str>
<arr name="skucode"><long>5076501</long></arr>
我已經使用xml文件將數據存儲在solr中。
它給出了can not sort on multivalued field: skucode
錯誤can not sort on multivalued field: skucode
或存儲無多值的數據
請讓我知道如何存儲不帶多值的數據或如何從后端更改。
僅當您要執行排序的字段是單值而不是多值時,查詢才有效。 您可以使用函數查詢對多值字段執行排序。
http://localhost:8983/solr/test_core/select?sort=field(skucode,max)+ASC&q=*skucode*&wt=xml
有關函數查詢的更多信息: -https : //cwiki.apache.org/confluence/display/solr/Function+Queries
您正在使用的查詢也可以使用的第二種方法是,您可以更改skucode的數據類型並將其設置為單個值。 為了使其單一值,在schema.xml中將skucode的數據類型從long更改為long。
<field name="skucode" type="long"/>
PS:-更改其數據類型后,您需要重新索引以反映您的更改
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.