Ronald Borla
Ronald Borla

Reputation: 586

Merge multiple exact query results in Sphinx Search

I need to search multiple exact keyword matches in Sphinx Search (PHP). For instance, I have the keywords (note that these are queried all at once):

"facebook user" "google plus member" "myspace fan"

The results should be able to return exact matches for each keyword above all combined in one result.

An example of the results I want it to show is:

  1. how to unfriend a facebook user
  2. myspace fan gets shot
  3. happy myspace fan posts a video on youtube
  4. unhappy google plus member
  5. facebook user who claims to be a cop
  6. funny google plus member

Notice that each result above have exact matches with any of the 3 keywords used. Somehow when I tried it in Sphinx, it doesn't work. Here's my code in PHP:

$sphinx->setMatchMode( SPH_MATCH_EXTENDED2 );
$sphinx->query( '"facebook user" "google plus member" "myspace fan"' );

What I did is to add quotes to each keyword to denote that I'm searching for exact matches, and just simply separated each keyword by spaces. Apparently, this doesn't work, so I need a good way to solve this.

Please help me with this, I'm not yet very familiar with Sphinx Search though. Thanks!

Upvotes: 0

Views: 1982

Answers (1)

Iaroslav Vorozhko
Iaroslav Vorozhko

Reputation: 1719

Checkout Extended query syntax. In your case you need | (OR) operator between phrases.

Upvotes: 1

Related Questions