Sphinx - Multiple fulltext search reduces exact match score

Viewed 172

I encountered a strange weight issue with Sphinx. When performed fulltext only on name, the results are weighted accurately. But when it's extended with search on address, the weight calculated is incorrect.

I'm using Sphinx 2.2.11

Example 1: Search on name yields proper results

$cl->SetRankingMode(SPH_RANK_SPH04);
$cl->SetSortMode(SPH_SORT_EXTENDED, '@weight desc');
$cl->SetMatchMode(SPH_MATCH_EXTENDED2);
$res = $cl->Query('@name ("la" | "comedie" | "saint" | "michel")', 'idx_name');

Output

      Venue Name                               Address          Weight
La Comédie Saint-Michel                 boulevard Saint-Michel  19620
La Comédie Saint-Michel - Small Hall    boulevard Saint-Michel  18649
La Comédie Saint-Michel - Grande Salle  boulevard Saint-Michel  18649

Words to match

[words] => Array
    (
        [la] => Array
            (
                [docs] => 26110
                [hits] => 29358
            )

        [comedie] => Array
            (
                [docs] => 89
                [hits] => 96
            )

        [saint] => Array
            (
                [docs] => 8820
                [hits] => 10171
            )

        [michel] => Array
            (
                [docs] => 314
                [hits] => 353
            )
    )

Example 2: Search on name and address gets incorrect weight

$cl->SetRankingMode(SPH_RANK_SPH04);
$cl->SetSortMode(SPH_SORT_EXTENDED, '@weight desc');
$cl->SetMatchMode(SPH_MATCH_EXTENDED2);
$res = $cl->Query('@name ("la" | "comedie" | "saint" | "michel")
                   @address ("boulevard" | "saint" | "michel")', 'idx_name');

Output

      Venue Name                               Address          Weight    
La Comédie Saint-Michel - Small Hall    boulevard Saint-Michel  32631
La Comédie Saint-Michel - Grande Salle  boulevard Saint-Michel  32631
La Comédie Saint-Michel                 boulevard Saint-Michel  32608

Words to match

[words] => Array
    (
        [la] => Array
            (
                [docs] => 26110
                [hits] => 29358
            )

        [comedie] => Array
            (
                [docs] => 89
                [hits] => 96
            )

        [saint] => Array
            (
                [docs] => 8820
                [hits] => 10171
            )

        [michel] => Array
            (
                [docs] => 314
                [hits] => 353
            )

        [boulevard] => Array
            (
                [docs] => 19735
                [hits] => 19915
            )
    )

In example 2, third record should have got highest weightage. Output expected is best/exact match to be on top. I tried using different ranking modes, but no luck.

0 Answers
Related