I'm trying to achieve two goals with the single Sphinx request: get results that match any word from query and have exact match on the first place. For example if I had song search request database:
- Miley Cyrus Ball
- Miley Cyrus Wrecking
- Miley Cyrus
And two test queries:
- Miley Cyrus
- Miley Cyrus Wrecking Ball
If I search for "Miley Cyrus" I want to get row #3 and if I search for "Miley Cyrus Wrecking Ball" I want to get #1 or #2. I tried different combination of matching and ranking modes but still can't get this working with the single request. When I try SPH_MATCH_EXTENDED2
and SPH_RANK_SPH04
my first test query works fine returning result #3 on the first place, but the second test query returns no results. When I try SPH_MATCH_ANY
I get partial matched results for the second test query (#2 has a bit higher weight which seems correct) but the first query returns 3 rows with the same weight and #1 is on top because of the order in the DB. The only workaround I have for now is making two queries: one for exact match and another one for partial match if the first one failed.
Also from this article I see that all match modes except SPH_MATCH_EXTENDED2
are legacy, so what should I use for partial match like in example above when they are removed?