简体   繁体   中英

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?

I have cloudsearch populated with Products. 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)

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?

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. 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). 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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