Log in
Model

Query

Magento\Search\Model\Query

What it does

This class manages search queries in Magento 2's search functionality.

Developers use it to store, retrieve, and track search terms entered by customers, including their popularity, number of results, and whether they should appear in search suggestions.

It validates query length against configured min/max limits and maintains search query statistics for improving search relevance and reporting.

Public Methods

  • getSearchCollection()
  • getSuggestCollection()
  • loadByQuery()
  • loadByQueryText()
  • setStoreId()
  • getStoreId()
  • prepare()
  • saveIncrementalPopularity()
  • saveNumResults()
  • getMinQueryLength()
  • getMaxQueryLength()
  • getQueryText()
  • isQueryTextExceeded()
  • isQueryTextShort()