Back to Typesense

Natural Language Search restaurants

docs-site/content/guide/reference-implementations/nl-search-restaurants.md

latest2.3 KB
Original Source

Natural Language Search restaurants

This demo restaurant search showcases the Natural Language Search feature of Typesense. This allows users to type a free-form sentence into the search bar. Typesense then leverages Large Language Models (LLMs) to understand users' intent, automatically translating the natural language query into structured search parameters like filters, sort orders, and relevant keywords.

This implementation uses Next.js 14 App Router for the front end, typesense-js client SDK for sending queries to Typesense, TanStack query for infinite scroll pagination, and gemini-2.5-flash-lite as the natural language search model.

Live Demo | Source Code

Key Highlights

  • Here's how to configure Typesense to create or update the natural language search model.
  • Here's an example of using a custom system prompt to fine-tune the model's behaviorfor this specific restaurant collection.
  • Here's how to perform a natural language search query using the typesense-js client SDK.
  • Here's how to implement pagination using the generated params of the initial search request.
  • Here's an example use case where the user's location is embedded in the query to enable geosearch for nearby restaurants.