gpt4 book ai didi

mysql - SOLR像mysql一样按field_in_set排序

转载 作者:行者123 更新时间:2023-11-29 21:02:19 25 4
gpt4 key购买 nike

我从 Solr 得到以下结果。

{
"responseHeader": {
"status": 0,
"QTime": 1,
"params": {
"sort": "ID DESC",
"indent": "true",
"q": "*",
"_": "1462775459580",
"wt": "json"
}
},
"response": {
"numFound": 10,
"start": 0,
"docs": [
{
"Name": "Info",
"AddedOn": "2016-04-19 00:46:10.0",
"BusinessName": "InfoSeffcon",
"ID": "389",
"LatLongCombined": "37.5641425,-122.00417900000002",
"_version_": 1533659952448536600
},
{
"Name": "QA 1 SP",
"AddedOn": "2016-03-20 22:02:16.0",
"ID": "344",
"LatLongCombined": "40.71364869999999,-74.00871259999997",
"_version_": 1533659952447488000
}

}

如何将 field_in_set 的顺序应用于 SOLR 查询。

基本上我想通过 ID 字段获取结果。

例如。如果我指定 ID:344,那么 344 的记录应该先出现,然后是其他记录。

我应该得到以下结果:

{
"responseHeader": {
"status": 0,
"QTime": 1,
"params": {
"sort": "ID DESC",
"indent": "true",
"q": "*",
"_": "1462775459580",
"wt": "json"
}
},
"response": {
"numFound": 10,
"start": 0,
"docs": [
{
"Name": "QA 1 SP",
"AddedOn": "2016-03-20 22:02:16.0",
"ID": "344",
"LatLongCombined": "40.71364869999999,-74.00871259999997",
"_version_": 1533659952447488000
},
{
"Name": "Info",
"AddedOn": "2016-04-19 00:46:10.0",
"BusinessName": "InfoSeffcon",
"ID": "389",
"LatLongCombined": "37.5641425,-122.00417900000002",
"_version_": 1533659952448536600
}
}

如何使用 SOLR 实现此目的。我对 SOLR 还很陌生,有人可以帮忙吗!

最佳答案

您可以使用字段进行排序。

id asc :按“id”字段升序排序

id desc :按“id”字段的降序排序

Solr Docs :可以对文档的 "score" 或任何 multiValued="false"indexed="true" 字段进行排序,前提是该字段是非标记化的(即:没有 Analyzer)或使用仅生成单个术语的分析器(即:使用 KeywordTokenizer)

关于mysql - SOLR像mysql一样按field_in_set排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37109256/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com