Question

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:

  • book_title weight: 10
  • book_description weight: 5
  • book_content weight: 1

How can I do it in sql query?

Was it helpful?

Solution

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)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top