开发者

How to optimize mysql full match

开发者 https://www.devze.com 2022-12-14 20:31 出处:网络
Hey guys, do you kn开发者_如何学编程ow some trick about how can I optimize more a full match search?

Hey guys, do you kn开发者_如何学编程ow some trick about how can I optimize more a full match search?

The code that I'm trying to optimize:

$do = $this->select()
      ->where('MATCH(`name`,`ort`) AGAINST( ? IN BOOLEAN MODE)', $theString)
      ->order('premium DESC');

The search should search for some companies...and let's say that in the field name I have: Google and in the ort field I have new york.

I want to do a query like: google center in new york and to give me as a result all the google centers from new york only!

I hope you understand what I mean!


use the relevance to sort

$do = $this->select("*, MATCH(`name`,`ort`) AGAINST ('{$theString}') AS score")
      ->where('MATCH(`name`,`ort`) AGAINST( ? IN BOOLEAN MODE)', $theString)
      ->order('premium DESC, score');


I think you should have a look at

  • Full-Text Search Functions
  • Using MySQL Full-text Searching


Your type of query might be matched better by a fulltext search in NATURAL LANGUAGE MODE instead of BOOLEAN MODE.

If you search for "google center in new york" in boolean mode you'll find any matches of all those keywords, but not necessarily in that order or matching those concepts.

0

精彩评论

暂无评论...
验证码 换一张
取 消