문제

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