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