Skip to content

Turn everyday language into relevant search results with Typesense's built-in Natural Language Search πŸ€–πŸ”βœ¨

Notifications You must be signed in to change notification settings

typesense/showcase-natural-language-search-restaurants

Repository files navigation

πŸ”₯ πŸ€– πŸ– Natural Language Search Restaurants powered by Typesense

This demo restaurant search showcases the new Natural Language Search feature powered by Typesense. This allows users to search for restaurants using everyday language.

Instead of needing to use specific keywords or precise filters, you can simply type a free-form sentence into the search bar. Typesense then uses Large Language Models (LLMs) to understand your intent, automatically translating your natural language query into structured search parameters like filters, sort orders, and relevant keywords.

This means you can find exactly what you're looking for with ease and flexibility, even if your exact keywords aren't in the restaurant's description. Experience a more intuitive and powerful way to discover your next dining destination!

This demo uses the dataset "TripAdvisor European restaurants" which is available on Kaggle.

Tech Stack

Project Structure

β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   └── restaurants.jsonl
β”‚   β”œβ”€β”€ indexTypesense.ts # script that create a collection and index data from restaurants.json into typesense server
β”‚   └── upsertModel.ts # create a Typesense natural language search model, update system_prompt if model already exists
└── src/
    β”œβ”€β”€ app/
    β”‚   └── page.tsx # main application
    β”œβ”€β”€ components/
    β”‚   └── UI components...
    β”œβ”€β”€ hooks/
    β”‚   └── getUserLocation.ts # provide the user location for the LLM to perform geosearch
    └── lib/
        β”œβ”€β”€ actions.ts # the search function used for pagination
        └── typesense.ts # typesense config

You can view the specific LLM instructions for this project in upsertModel.ts

Development

To run this project locally, make sure you have docker and nodejs, clone this project, install dependencies and start the dev server:

Start typesense server

npm run start:typesense # or: docker compose up

Index data into typesense

npm run index:typesense

Create a natural language search model, this script is also used to update the model's system_prompt.

npm run createModel:typesense

Start the dev server

npm run dev

Open http://localhost:3000 to see the app ✌️

Deployment

See .env.example for environment variables.

About

Turn everyday language into relevant search results with Typesense's built-in Natural Language Search πŸ€–πŸ”βœ¨

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published