Zabs
Zabs

Reputation: 14142

Sphinx - Need to work out which index each search result is coming from (has 4 indexes)

I have used the following Sphinx example on my website, it works ok however as I have indexed multiple tables - I need to be able to work out which table each search result is coming from and generate a URL accordingly. http://www.nearby.org.uk/sphinx/example5.php?q=test (note this isn't my site)

My code (minus the MySQL connection details on pastebin) http://pastebin.com/brbUu5VD

eg.. if it is a news article... something like this..

mysite.com/news/view/123/my-page-title

if is an library article then it would alter slightly

mysite.com/library/view/99/article-title

Can anyone suggest how this would be done - thanks in advance

Upvotes: 0

Views: 117

Answers (1)

barryhunter
barryhunter

Reputation: 21091

The easiest way to to add a new attribute to your indexes.

Eg

index 1
sql_query = SELECT id, 1 as table_id, .... 
sql_attr_uint = table_id

index 2
sql_query = SELECT id, 2 as table_id, .... 
sql_attr_uint = table_id

you get that attribute back in search results, which you can then use to create the link.

Upvotes: 1

Related Questions