Sadly, it seems it wasn't been done so far. It's either custom similarity
or function query.

On Thu, Nov 6, 2014 at 9:40 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
>



-- 
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics

<http://www.griddynamics.com>
<mkhlud...@griddynamics.com>

Reply via email to