弹性搜索,巢。功能分类 [英] Elastic Search, Nest. functional sorting

查看:181
本文介绍了弹性搜索,巢。功能分类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个过滤器页面,其中的方面等等,它应该是正常的。
现在我们的客户有一个要求,基本上是能够决定哪些排序的项目出来。
每个产品都装有产品展示订单,并在产品线中。

I'm building a filter page, with facets etc, which works as it should. Now the our customer has a request to, basically "Be able to decide which sorting the items comes out in". Each product is decorated with a Product Display Order, and is in a Product Line.

我们得到了这些示例产品展示订单:
1。特色项目
2.核心项目
3.备件
4.实用程序

We got these example Product Display Orders: 1. Featured Item 2. Core Item 3. Spare Part 4. Utility

这些产品线:
1 。锤子
2.锯
3.木材

And these Product Lines: 1. Hammers 2. Saw 3. Wood

,排序如下:
排序应首先基于产品展示订单,其次是产品线,第三名。
所有所有属于特色项目的产品列在第一位,所有这些精选项目都按照产品线排序,如果某些产品在相同的特色项目和产品线,然后按字母顺序排列。

and the sorting is like this: Sorting should firstly be based on Product Display Orders, secondly by product lines, thirdly Alphabetically. So all products which is a Featured Item is listed first, and all these Featured Items is then sorted by their product line, and if some product are in the same Featured Item and Product Line, then its alphabetically.

面临的挑战是:我不能仅仅在产品上获得产品展示订单项目和产品系列的排序,我只收到一个名称/ ID。

The challenge is: I can't just get the sorting of Product Display order items and product lines as a number on the product, i only got a name/id.

根据产品是否属于不同的类别,我们考虑过Boosting,但似乎有点混乱。

We've thought of Boosting based on if the product are in the different categories, but it seems a bit messy.

查看排序中是否可能有一些逻辑。
按productDisplayOrder排序:
1.特色,2.核心项目...
然后由ProductLines:
1.锤子,2.锯...
然后通过名称DESC。

See if it possible to have some logic in the Sorting. Sort by productDisplayOrder: 1. featured, 2. core Item ... Then by ProductLines: 1. Hammers, 2. Saw ... Then by Name DESC.

哪种方式是进行排序的最佳方法,是否可以将此逻辑赋予弹性,如果它是一个匹配,然后排序。或者我们需要扭转产品的提升吗?

Which way is the best way to have this sorting, is it possible to give this logic to elastic, if it is a match and then sort it. Or are we needed to twist the boosts of product?

希望这对您有意义。
提前感谢! :)

Hopefully this makes sense for you. Thanks in advance! :)

推荐答案

选项1)。最快/最好的解决方案是为 productDisplayOrder ProductLine 创建新的/单独的整数字段,然后使用按照所描述的排序条件(重建索引并验证数据按预期的方式进行索引)。

Option 1). Quickest/Best performing solution would be to create new/separate integer fields for productDisplayOrder and ProductLine and then use those in your sort criteria as described (after reindexing and validating the the data is indexed as expected).

选项2)如果您想要比描述更多的细微差别(例如较高的得分匹配可以突破描述的排序上限),那么您可以使用功能分数查询实现自定义在生成整体匹配分数时考虑到 productDisplayOrder ProductLine 的评分策略。

Option 2) If you want more nuance than described (eg higher scoring matches can 'break through' the ordering ceiling described) then you can explore using a Function Score Query to implement a custom scoring strategy that takes productDisplayOrder and ProductLine into consideration in generating an overall match score.

选项3)。如果您无法更改数据的映射和重新索引,则可以使用基于脚本的排序可以使用脚本(例如Groovy)从当前索引的productDisplayOrder / ProductLine文本生成排序值。请记住,查询性能会比前两个选项差。

Option 3). If you can't change the mapping and reindexing your data, you can use Script-Based Sorting to generate sorting values from the currently indexed productDisplayOrder/ProductLine text using a script (eg Groovy). Keep in mind that query performance will be worse than the first two options.

这篇关于弹性搜索,巢。功能分类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆