Exact search plus pinyin search plus fuzzy search

Source: Internet
Author: User

1, if the input name and the name of the library exactly match the exact search

2, if the input name in the content contains information in the fuzzy matching

3. If the search has no results, convert the name into pinyin for searching

/**  *  exact search or fuzzy search   * enter description here ...  *   @param  string  $title   *  @return  array 1 precise   2 Blur   * / public function search ($title)  {  if  (empty  (  $title  ))  {   return;  }   $title  = urldecode  (  $title   );   $goods  =  $this->getgoodsbyname  (  $title  )     if   (! empty  (  $goods  ))  {    $rs  =  $this getgoodsmxbysku  (  $goods  [' sku '] );   return array  (' status '  => 1,  ' data '  =>  $rs  );  }     $rs  =   $this->getgoodsliketitle  (  $title  );  return array  (' status '   => 2,  ' Data '  =>  $rs  )   }  private function getgoodsliketitle ($title)  {      $py  = Pinyin::utf8_to  (  $title, true );  if  (!strpos   (  $title,  "_"  )  {    $rs  = BuyModel::instance  () getgoodslikepinyin  (  $py  );  } else {    $rs  =  buymodel::instance  ()->getgoodsliketitle  (  $title  );  }   $goods  =  $this->parsegoodsstatus  (  $rs  );  return  $this getgoodsimagebysku  (  $goods  );  }

Exact search plus ruby search plus fuzzy search

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.