Log in
Factory

QueryFactory

Magento\Search\Model\QueryFactory

What it does

This factory class creates and retrieves search Query objects in Magento 2.

Developers use it to get the current search query from the request, which includes validation for minimum/maximum query length and proper text sanitization.

It's the primary way to access search query data throughout the application.

Public Methods

  • get()
  • create()