Вопрос

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?

Это было полезно?

Решение

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)
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top