简体   繁体   English

传递AWS Cloudsearch查询的特定退货顺序

[英]Passing in specific return order for AWS Cloudsearch query

Is there a way that I am able to tell a cloudsearch query that I want to get the matching results back in a specific order? 有没有一种方法可以告诉cloudsearch查询我要以特定顺序返回匹配结果?

I have cloudsearch populated with Products. 我已经在Cloudsearch中填充了“产品”。 For each User, I have a predefined order that I want those products to appear. 对于每个用户,我都有一个预定义的订单,希望这些产品出现。 The user can filter the Products by a number of fields, and this will call Cloudsearch and return the matches, 10 at a time (ajax loaded paged results) 用户可以按多个字段过滤产品,这将调用Cloudsearch并一次返回10个匹配项(ajax加载分页结果)

How can I tell Cloudsearch that once it has found those matches, I want them to be returned in the predefined order for this particular customer? 我怎样才能告诉Cloudsearch,一旦找到这些匹配项,我希望以特定客户的预定义顺序返回这些匹配项?

Ok so it's infeasible to index the ranking for each user and I'm assuming the ranking is arbitrary and not something that could be expressed in a CloudSearch rank expression. 好的,因此无法为每个用户建立排名索引,并且我假设排名是任意的,而不是可以在CloudSearch排名表达式中表达的内容。 Within the constraints you've set, I don't think there's a great way to do this. 在您设置的约束范围内,我认为没有很好的方法可以做到这一点。

The best I can come up with would be something like getting all the results for a query and then sorting them based on the ranking in your DB. 我能想到的最好的方法是获取查询的所有结果 ,然后根据数据库中的排名对它们进行排序。 CloudSearch is fairly fast and you should be able to request result sets of a few thousand (in my index of 40k docs, returning a set of 1000 results took ~400ms). CloudSearch相当快,您应该能够请求几千个结果集(在我的40k文档索引中,返回1000个结果集花费了大约400毫秒)。 You'd then have to sort those according to their rank in your datastore. 然后,您必须根据它们在数据存储区中的排名对它们进行排序。 It feels very wasteful but it may be the best you can do with the constraints you're working in. 感觉很浪费,但是对于您正在处理的约束,这可能是最好的选择。

Or you could get the top n items for that user from your database , and hit CloudSearch with the user's query, checking for those top n items in the results (this could actually be part of the query) and paging through search results until you've found enough (10 in your case) to display them to the user. 或者,您可以从数据库中获取该用户的前n项 ,然后用该用户的查询命中CloudSearch,检查结果中的前n项(这实际上可能是查询的一部分),并在搜索结果中分页直到您已经找到了足够的数据(在您的情况下为10个)显示给用户。

Given the inefficiency of the above solutions, I'd urge re-evaluating your constraints: ranking search results should really be the responsibility of the search engine ; 鉴于上述解决方案的效率低下,我强烈建议您重新评估您的约束条件:对搜索结果进行排名应真正由搜索引擎负责 separating that responsibility, creates a messy handoff that ideally shouldn't exist. 分离责任,创建一个混乱的交接,理想情况下不应该存在。 Maybe you can come up with a replacement for the third-party ranking algorithm that can be expressed as a rank expression; 也许您可以提出一个第三方排名算法的替代品,该算法可以表达为排名表达; maybe you can do filtering in through your database queries instead of using cloudsearch. 也许您可以通过数据库查询进行过滤,而不是使用cloudsearch。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM