Hi Trey, In an application I built few years ago, I had a component that rewrote the input query into a Lucene BooleanQuery and we would set the minimumNumberShouldMatch value for the query. Worked well, but lately we are trying to move away from writing our own custom components since maintaining them across releases becomes a bit of a chore.
So lately we simulate this behavior in the client by constructing progressively smaller n-grams and OR'ing them then sending to Solr. For your example, it becomes something like this: (python AND solr AND hadoop) OR (python AND solr) OR (solr AND hadoop) OR (python AND hadoop) OR (python) OR (solr) OR (hadoop). -sujit On Thu, Nov 6, 2014 at 7:25 AM, Ahmet Arslan <iori...@yahoo.com.invalid> wrote: > Hi Trey, > > Not exactly the same but we did something similar with (e)dismax's mm > parameter. By autoRelax'ing it. > > In your example, > try with mm=3 if numFound < 20 then try with mm=2 etc. > > Ahmet > > On Thursday, November 6, 2014 8:41 AM, Trey Grainger <solrt...@gmail.com> > wrote: > > > > Just curious if there are some suggestions here. The use case is fairly > simple: > > Given a query like python OR solr OR hadoop, I want to sort results by > "number of keywords matched" first, and by relevancy separately. > > I can think of ways to do this, but not efficiently. For example, I could > do: > q=python OR solr OR hadoop& > p1=python& > p2=solr& > p3=hadoop& > sort=sum(if(query($p1,0),1,0),if(query($p2,0),1,0),if(query($p3,0),1,0)) > desc, score desc > > Other than the obvious downside that this requires me to pre-parse the > user's query, it's also somewhat inefficient to run the query function once > for each term in the original query since it is re-executing multiple > queries and looping through every document in the index during scoring. > > Ideally, I would be able to do something like the below that could just > pull the count of unique matched terms from the main query (q parameter) > execution:: > q=python OR solr OR hadoop&sort=uniquematchedterms() desc,score desc. > > I don't think anything like this exists, but would love some suggestions if > anyone else has solved this before. > > Thanks, > > -Trey >