How to check elasticsearch is enabled programmatically Magento 2?

Magento 2.4 Out of the box supports Primary Search Engines is Elasticsearch.

If your site having some third party search engine installed or want to know about programmatically for the elastic search is enable or not in your code, you can know it using the given code snippet. Continue reading “How to check elasticsearch is enabled programmatically Magento 2?”

How to apply custom conditions before get faceted data elastic search results Magento 2?

Apply custom conditions on faceted data elastic search collection before it returns field faceted data from the faceted search results in Magento 2.

From the Magento 2.4, Elasticsearch is the Primary search engine instead of Deprecated Mysql.

When you go to the Catalog search module, FullText collection class, you can check the getFacetedData() method to return the field with faceted search results. Using Before plugin, you can add custom conditions before final search results render on the page. Continue reading “How to apply custom conditions before get faceted data elastic search results Magento 2?”

What is the use of search_query table in magento 2?

In Magento 2 search_query database table store the search query, which users have searched using the search box in Magento 2.
— query_text field in a search_query table in stores the value of search string. When User search through site, all of the search entry will be added to search_query table in query_text field.
num_results field used for Number of results for specific word in the site. That field show count of any string search in site.
— popularity field is displayed popularity of specific word in your site, the Biggest number will have the most popular search word for your site.
store_id will show search from a specific store.
There are some other field also available in search_query table but above field is the main field of a table.

You can check from the admin panel, all of the search query will be shown from Search Terms sectino.
Click on Marketing -> SEO & Search -> Search Terms
You will get all the search result grid for your site.