Tom Tichý
Tom Tichý

Reputation: 1065

Set weight to columns in Sphinx SQL

I have query to sphinx index like this:

SELECT author_id 
  FROM books 
 WHERE MATCH(%s) 

and I want to set specific weight to columns. For example column book_title is much more important than book_description and it is more important than book_content.

For example I would set:

How can I do it in sql query?

Upvotes: 2

Views: 2360

Answers (1)

Ulrich Thomas Gabor
Ulrich Thomas Gabor

Reputation: 6654

Please see in the manual that you can pass field_weights on a per-query basis with the OPTION keyword. In your case you might want to use

SELECT * FROM books WHERE MATCH(%s)
OPTION field_weights=(book_content=1, book_description=5, book_title=10)

Upvotes: 4

Related Questions