Search code examples
phpsphinx

Sphinx Get Word in Result through PHP API


The Sphinx PHP API returns a "matches" array after executing "Query();". It also returns a "Words" array. What I'm wondering is if there is a way that for each match in the "matches" array if it would show what word was used to give that result it's weight.

For example, my query is... "Green Banana | Yellow Banana"

The results look something like.

[18403206462384766539] => Array
            (
                [weight] => 4553
                [attrs] => Array
                    (
                    )

            )

What I'd love to see is something more like.

[18403206462384766539] => Array
            (
                [weight] => 4553
                [attrs] => Array
                    (
                    )
                [word] => "Green Banana"
            )

I want to avoid having to make two separate queries and then having to compare the weights across both result arrays to find the highest one because I plan on having a query with many hundreds or thousands of OR'd phrases.


Solution

  • Not really. There is however PACKEDFACTORS() - which might give you some useful information.

    Its a function so can be used in the `SetSelect call.