具体命令文件 Solr(或ES)
Specific order of documents Solr (or ES)
好的,我的工作是在包含 Solr 结果的类别页面上创建一个特定的订单,我认为这很难实现。
工作:
- 类别页面的前 2 个产品必须是精选产品或点击次数最多的产品。
- 其他产品必须按时间顺序排列,但每个供应商最多有 2 个产品相邻。
所以:
1. tv from LG (fixt)
2. radio from Pioneer (fixt)
3. pc monitor from Samsung (chronologic)
4. smartphone from Samsung (chronologic)
5. smartphone from LG (chronologic)
6. dj set from Pioneer (chronologic)
因此每个供应商最多 2 个产品并排放置。类别页面可以包含比方说 10 个三星产品,但不是彼此相邻。 ONLY of there are no products from other suppliers leave,那么可以将它们并排放在类别的末尾。所以:
1. samsung product
2. samsung product
3. lg product
4. hp product
5. hp product
6. samsung product
7. hp product
8. hp product
9. hp product
10. hp product
11. hp product
12. hp product
13. hp product
如你所见。如果所有供应商产品都完成了,只剩下一个(hp),就全部显示。
我能够使用复杂的 SQL 函数创建主页,其中每个类别仅显示 10 个产品。但是现在他们也希望在整个类别页面上看到相同的顺序,并且这些页面包含来自 Solr 的结果....所以有人知道或者可以使用 Solr 或 ElasticSearch 创建这样的顺序吗?
我们刚刚开始实施 Solr,所以如果有必要为此使用 ElasticSearch,那也是可能的。
编辑:
我读到这应该可以通过一些 JAVA 编程实现:http://sujitpal.blogspot.nl/2013/03/solr-custom-ranking-with-function.html and http://www.supermind.org/blog/756/how-to-write-a-custom-solr-functionquery 以前有人做过吗?一件事:我不想 "boost" 文件,我真的希望最多 2 个供应商并排,所以一个真正具体的订单。谁知道这个应该可以吗?
排序或评分是按文档进行的,而不是在全局上下文中进行的,因此我认为您无法使用相同的方法来实现。
但是,您可以使用 top_hits 来实现类似的效果,而且效果很好。
{
"query": {},
"aggs": {
"perSupplier": {
"terms": {
"field": "supplier"
},
"aggs": {
"TwoDocs": {
"top_hits": {
"size": 2
}
}
}
}
}
}
好的,我的工作是在包含 Solr 结果的类别页面上创建一个特定的订单,我认为这很难实现。
工作:
- 类别页面的前 2 个产品必须是精选产品或点击次数最多的产品。
- 其他产品必须按时间顺序排列,但每个供应商最多有 2 个产品相邻。
所以:
1. tv from LG (fixt)
2. radio from Pioneer (fixt)
3. pc monitor from Samsung (chronologic)
4. smartphone from Samsung (chronologic)
5. smartphone from LG (chronologic)
6. dj set from Pioneer (chronologic)
因此每个供应商最多 2 个产品并排放置。类别页面可以包含比方说 10 个三星产品,但不是彼此相邻。 ONLY of there are no products from other suppliers leave,那么可以将它们并排放在类别的末尾。所以:
1. samsung product
2. samsung product
3. lg product
4. hp product
5. hp product
6. samsung product
7. hp product
8. hp product
9. hp product
10. hp product
11. hp product
12. hp product
13. hp product
如你所见。如果所有供应商产品都完成了,只剩下一个(hp),就全部显示。
我能够使用复杂的 SQL 函数创建主页,其中每个类别仅显示 10 个产品。但是现在他们也希望在整个类别页面上看到相同的顺序,并且这些页面包含来自 Solr 的结果....所以有人知道或者可以使用 Solr 或 ElasticSearch 创建这样的顺序吗?
我们刚刚开始实施 Solr,所以如果有必要为此使用 ElasticSearch,那也是可能的。
编辑: 我读到这应该可以通过一些 JAVA 编程实现:http://sujitpal.blogspot.nl/2013/03/solr-custom-ranking-with-function.html and http://www.supermind.org/blog/756/how-to-write-a-custom-solr-functionquery 以前有人做过吗?一件事:我不想 "boost" 文件,我真的希望最多 2 个供应商并排,所以一个真正具体的订单。谁知道这个应该可以吗?
排序或评分是按文档进行的,而不是在全局上下文中进行的,因此我认为您无法使用相同的方法来实现。
但是,您可以使用 top_hits 来实现类似的效果,而且效果很好。
{
"query": {},
"aggs": {
"perSupplier": {
"terms": {
"field": "supplier"
},
"aggs": {
"TwoDocs": {
"top_hits": {
"size": 2
}
}
}
}
}
}