Silver Light
Silver Light

Reputation: 45902

Search across different indexes using sphinx

We are trying to make a site-wide search using sphinx. This means, that our search must look at all the main indexes and fields in them and return them by relevance.

This is the query:

SELECT *
          FROM articles, users, genres
          WHERE match ('@(articles.title, genres.title, articles.description, users.nickname) test_sting')

But this does not seem to work. Is there any way to search across multiple indexes and specify the fields that we want to search?

Upvotes: 0

Views: 74

Answers (1)

barryhunter
barryhunter

Reputation: 21091

SELECT * FROM articles, users, genres WHERE match ('test_sting')

should just match all fields in all indexes, no need to specify the specific fields.


Otherwise you can use the barely documented @@relaxed operator....

SELECT * FROM articles, users, genres
      WHERE match ('@@relaxed @(title, description, nickname) test_sting')

which should work. It will only search those named fields, but the @@relaxed, means it doesnt matter if a particular field doesnt exist in a particular index.

Upvotes: 1

Related Questions