I think this solution will destroy intra-query ranking. So all results in q0 come before q1 but would be random within q0 results.
Would instead just a bunch of boost queries with different weights (additive probably) be a beter way to introduce stratification? Regards, Alex On Thu, Jun 7, 2018, 13:19 Emir Arnautović, <emir.arnauto...@sematext.com> wrote: > Hi Robert, > If I get your requirement right, you can solve it with following: > (q0)^=100 OR (q1)^=90…. > > Assuming there are no overlaps - otherwise, one matching multiple > conditions can change the ordering. > > HTH, > Emir > -- > Monitoring - Log Management - Alerting - Anomaly Detection > Solr & Elasticsearch Consulting Support Training - http://sematext.com/ > > > > > On 7 Jun 2018, at 11:53, Robert K. <wk.rk.sk...@mail.ru.INVALID> wrote: > > > > Hello, > > > > I am investigating the following use case. > > > > Suppose I have a list of queries q_0, q_1, ..., q_n which I combine to a > boolean query using 'SHOULD'-clauses. > > The requirement for the hits sorting is that the results of q_0 precede > the results of q_1, the results of q_1 precede the > > results of q_2 an so on. If a hit occurs in the results of more then one > query, then we should see it only once in the results > > of the query with the smallest index. > > > > I have searched for some solutions but didn't find anything useful so > far. > > > > I have considered following approaches: > > > > 1. Reformulate: q0 & (q_1 & !q_0) & (q2 & !q_0 & !q1) & ... > > > > While possible, seems to have a potential negative impact on performance > due to multiple evaluations on the same queries. > > I didn't do any measurements, though. It is technically possible to > optimize the execution of this query to evaluate the subqueries > > q_i only once, but I don't know, whether this kind of optimizations is > implemented in the current Lucene/Solr. (?) > > > > 2. Implement CustomScoreQuery. General idea: Take a list of queries and > execute them in the context of a BooleanQuery mapping > > the scores of the corresponding subqueries to disjunct score ranges, > like q_n -> [0,1), q_(n-1) -> [1,2) and so on. > > > > Problem: CustomScoreQuery is deprecated, FunctionQuery is the recommeded > approach. Still I didn't see any obvious solution > > how I can use FunctionQuery to implement the idea. Is it possible, > should I dive in and try to do it with FunctionQuery. > > > > 3. Assuming there is some possibility to solve the task with the > FunctionQuery (or anything within the out-of-the-box Solr). My questions > > are: Is there any solution without having to write our own extension to > Solr? Using only what is delivered in the standard distribution of Solr? > > > > > > Note: In the past we solved the problem within our legacy application > with a modified BooleanQuery/BooleanScorer. We could migrate > > (=rewrite) this extension to the current Solr/Lucene, but it may be not > the best option, so I am exploring all the other possibilities. > > > > Thank you all & Best regards, > > > > Robert > >