solr查询根据价格按降序对结果进行排序
solr query to sort result in descending order on basis of price
我对 Solr 非常陌生,我正在尝试查询我的数据。我正在尝试查找 name=plant 的数据并按最高价格排序
我的名称和价格架构都是文本类型。
例如假设数据是
name:abc, price:25;
name:plant, price:35;
name:plant,price:45; //1000 other data
我的方法
/query?q=(name:"Plant")&stopwords=true
但上面给出了植物的结果,但我不确定如何使用价格字段对结果进行排序
任何帮助将不胜感激
您可以使用排序参数来实现排序。
您的查询应该是 q=(name:"Plant")&sort=price desc
The sort parameter arranges search results in either ascending (asc)
or descending (desc) order. The parameter can be used with either
numerical or alphabetical content. The directions can be entered in
either all lowercase or all uppercase letters (i.e., both asc or ASC).
Solr can sort query responses according to document scores or the
value of any field with a single value that is either indexed or uses
DocValues (that is, any field whose attributes in the Schema include
multiValued="false" and either docValues="true" or indexed="true" – if
the field does not have DocValues enabled, the indexed terms are used
to build them on the fly at runtime), provided that:
the field is non-tokenized (that is, the field has no analyzer and its
contents have been parsed into tokens, which would make the sorting
inconsistent), or
the field uses an analyzer (such as the KeywordTokenizer) that
produces only a single term.
我对 Solr 非常陌生,我正在尝试查询我的数据。我正在尝试查找 name=plant 的数据并按最高价格排序
我的名称和价格架构都是文本类型。
例如假设数据是
name:abc, price:25;
name:plant, price:35;
name:plant,price:45; //1000 other data
我的方法
/query?q=(name:"Plant")&stopwords=true
但上面给出了植物的结果,但我不确定如何使用价格字段对结果进行排序
任何帮助将不胜感激
您可以使用排序参数来实现排序。
您的查询应该是 q=(name:"Plant")&sort=price desc
The sort parameter arranges search results in either ascending (asc) or descending (desc) order. The parameter can be used with either numerical or alphabetical content. The directions can be entered in either all lowercase or all uppercase letters (i.e., both asc or ASC).
Solr can sort query responses according to document scores or the value of any field with a single value that is either indexed or uses DocValues (that is, any field whose attributes in the Schema include multiValued="false" and either docValues="true" or indexed="true" – if the field does not have DocValues enabled, the indexed terms are used to build them on the fly at runtime), provided that:
the field is non-tokenized (that is, the field has no analyzer and its contents have been parsed into tokens, which would make the sorting inconsistent), or
the field uses an analyzer (such as the KeywordTokenizer) that produces only a single term.