3

I am working on magento 2.1.3.

Is there any possibility to search with 2 characters using catalog search?

Now i can't able to search terms like tv.

4

I do not know your search engine, I suppose that you use Mysql. It works out of the box with ElasticSearch.

Resolution :

First set the minimun search characters to 1 in Magento configuration : Admin -> Stores -> Configuration -> Catalog -> Catalog -> Catalog Search

The data indexed (catalogsearch_fulltext_scope1) looks like :

*************************** 1. row ***************************
   entity_id: 45
attribute_id: 73
  data_index: tv

The SQL query for 'tv' request:

SELECT `main_select`.`entity_id`, MAX(score) AS `relevance` FROM (SELECT `search_index`.`entity_id`, ((0) + LEAST((MATCH (data_index) AGAINST ('tv' IN BOOLEAN MODE)), 1000000) * POW(2, search_weight)) AS `score` FROM `catalogsearch_fulltext_scope1` AS `search_index` LEFT JOIN `catalog_eav_attribute` AS `cea` ON search_index.attribute_id = cea.attribute_id LEFT JOIN `cataloginventory_stock_status` AS `stock_index` ON search_index.entity_id = stock_index.product_id AND stock_index.website_id = 0 WHERE (stock_index.stock_status = 1) AND (MATCH (data_index) AGAINST ('tv' IN BOOLEAN MODE))) AS `main_select` GROUP BY `entity_id` ORDER BY `relevance` DESC LIMIT 10000

If you check Mysql documentation, there are two parameters for Configuring Minimum and Maximum Word Length :

http://dev.mysql.com/doc/refman/5.7/en/fulltext-fine-tuning.html

So edit your my.cnf file, add these parameters :

ft_min_word_len = 1
innodb_ft_min_token_size = 1

Restart mysql

service mysql restart

Rebuild your index

bin/magento indexer:reindex

Then you will see your product on the search result page.

  • Moreover for information, Mysql search engine will be depraciated and replaced by ElastiSearch – Franck Garnier Nov 20 '18 at 8:44
2

In my case i needed 'edit' this file:

vendor\magento\framework\Search\Adapter\Mysql\Query\Builder\Match.php

There was a constant and ignore config from backend

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.