We, at CodeHunger (a web solutions and mobile app development company), understand the importance and
results of having aptly developed websites with great web design and user experience. Our web
development is optimized for search engines to get more website traffic or you can say SEO friendly,
for social media and digital marketing.
Contact Us
Our Company is located at the heart of bihar patna city, Our Company Address is Rai Jai Krishna Road,
Gurhatta Patna City, Near Shiv Mandir - 800008
Laravel Scout with Typesense: Handling “Parameter Fields is Required” Error
Laravel Scout is a powerful driver-based full-text search package for Laravel. While it supports Algolia out of the box, developers often integrate it with Typesense, an open-source typo-tolerant search engine known for blazing-fast performance.
However, during integration, many developers encounter the error:
[Typesense\Error\ObjectUnprocessable]: Parameter 'fields' is required.
Let’s understand why this happens and how to resolve it with an example.
Why Typesense Needs the fields Parameter
When you perform a search in Typesense, you must specify which fields to search against in your collection schema. Unlike Algolia, which can auto-search across all indexed fields, Typesense enforces this for performance optimization.
Typical Scenario
Suppose you have a products collection indexed with these fields:
id (int)
name (string)
description (string)
price (float)
When you send a search query without specifying query_by (equivalent to fields), Typesense throws:
[Typesense\Error\ObjectUnprocessable]: Parameter 'query_by' is required.
This indicates that your Laravel Scout query is missing the fields parameter Typesense needs to process the search.
Solution for the above issue is that, you haven't passing the field correctly to scout, go to the scout.php and add your model and field value like the below one I have done,
Typesense with Laravel Scout is a performance-optimized alternative to Algolia, giving you data sovereignty and speed. However, understanding Typesense’s strict schema requirements such as the query_by parameter is essential to avoid errors like:
Parameter 'fields' is required.
Always define your searchable fields in your model via typesenseQueryBy() for clean, scalable, and error-free search implementation.