I thought it is rather common case, but just can't figure out and find any info about it.
Say I have following texts:
I can't figure out query, which returns texts in following order:
1) First all texts which contains ALL three 'dog', 'cat' and 'mice',
2) Then all texts which contains each pair of ('dog', 'cat'), ('dog', 'mice'), ('cat', 'mice') in no particular order
3) Then all texts which contains any of 'dog', 'cat' or 'mice'
So result of such query for given texts should be something like this (preferably shorter text first, but not necessarily)
Could anybody help me please?
Well in general there are two parts to it, Matching and Ranking.
For matching you just want documents that contain at least one of the words (ie will accept a document with jsut one of them). The quorum operator is probably easiest way of doing that, but a few other methods would work too.
... MATCH(' "dog cat mice"/1 ')
Then you want to make the ones with most words (3) show first - which is about ranking http://sphinxsearch.com/docs/current.html#ranking-overview
in general might well find the WordCount Ranker is ok for your situation
... OPTION ranker=wordcount
But read the above section on ranking, there is much more elaborate ranking that cound be done.
With ranking, you need to get into the mindset of thinking how sphinx computes a score for each result, and then just orders the results in descending weight order. (as opposed to 'this, then that, then that'. )
Edit to add: you mention dog
being a query term, but have documents containing dogs
so do make sure look at morphology and stemming to account for that.
http://sphinxsearch.com/docs/current.html#conf-morphology