Debugging the Search

Introduction

Your shop search does not provide you with the results you are looking for? Then you are exactly right here! We will check some points so you can quickly check if the shopware search does exactly what the search should do.

Please note that the search will not give you any results if more than ≈80 % of your article master would be returned as results.

Check the search index

First of all, it is important to determine whether the search index was built up completely. This can be found in your database. Go to your database and search for the table s_search_keywords. If there are entries for the column "Soundex" set to NULL for a keyword which have no number as an entry, this is an indication that the search index was not built up correctly. 

Strategy for building the search index

To be able to analyze the described behavior more precisely you should first check how the search index is built up in your shop. To do this, go to Settings > Cache/Performance > Settings (tab) > search (left), which is selected here as a corresponding strategy for the structure for the search index.

If the "Live" option is used to build the search cache, this generates a certain number of entries for each page call in the frontend or checks for actuality. The search index is updated very frequently in your shop. Especially since the Fuzzy search is a "learning" search, some search queries would be necessary here in order to provide optimal search results. During this time suboptimal search results could occur. The update strategy "Live" also has the disadvantage that additional server load is generated with each call in the front end. In terms of performance, this setting is not recommended.

To limit this behavior, we recommend you change the search strategy to "Cronjob". With the use of cronjobs you can move the load also collected at night.

If this does not help again, we recommend you that you try to build the search index on the console: php bin/console sw:refresh:search:index

Did you get an error message similar like this:


PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 72 bytes)

So you should try to set the memory_limit higher. Depending on the system this already works with the following extension of the CLI call with: -d memory_limit = 4096M Thus: php -d memory_limit = 4096M bin/console sw:refresh:search:index

If the search index cannot be built up due to a standard batch size of 4000, you can get around this quickly and easily by adapting the config.php on your server.

To do this, put the following into your config.php:


'search' => [
'indexer' => [
'batchsize' => 3250,
            ],
         ],

If you have further questions about the memory_limit, you can contact your hosting partner directly.

Debug with the Fuzzy Search preview

If you do not find the desired results with your search, you can use the Fuzzy Search preview here. If the information of the preview with the data of the factor and the relevance does not provide the desired information, You can use Google Chrome's Developer Tools.

Here you can find a list-egg under the Network


DeinShop.de/backend/SwagFuzzyPreview/list?_dc=1486566464437&shopId=1&page=1&start=0&limit=20&filter=%5B%7B%22property%22%3A%22search%22%2C%22value%22%3A%22Lachs%22%2C%22operator%22%3Anull%2C%22expression%22%3Anull%7D%5D

With this entry, you can quickly see what the search term is and what keywords are found and used here. In addition, you will get an overview of how many search terms were found. If you would now suspect that your search term is pretty close to the given search terms but nevertheless it is not listed as a term, then you should increase the value "Maximum number of displayed results and the used keywords" for the search. Here you can specify how much deviating keywords are used for the search.

Products with long product names are not found

If you have long product names that you can not find, you can create individual keywords for these long compiled product names. In addition you should increase the relevance for the keyword.

Example: Donaudampfschifffahrtsgesellschaftskapitänsmütze

Keywords: Donau dampf schiff fahrts gesellschaft kapitän mütze Donaudampf schifffahrt gesellschaft kapitänsmütze Donaudampfschifffahrt gesellschaft schifffahrtgesellschaft kapitänsmütze

Check the search logic

If you do not find products when you are using multiple keywords, you can check the search logic used.

You can find them under: Settings> Preferences> Storefront> Search> "And" Use Search Logic: No

Afterwards, you can rebuild the search index via: Settings> Cache / Performance> Settings> Search> Rebuild search index.

When this is done. Clear the cache (CTRL + ALT + X) and reload the backend (CTRL + F5).

Check product numbers

In general, it is important to make sure that you use the correct article numbers when searching. Information about the article numbers supported in Shopware can be found in the Wiki article on article numbers.

If multiple searchterms switching directly to a product you may have a product with a defective ordernumber. The best way to check this is to look up the database in the table s_products_details to see if there is an product that has no or only 2 characters as ordernumber.  

Wiki article for the Smart Search

Was this article helpful?