Loading...

Searchable fields

Your movies list works, but a visitor can only find a film if they type its exact title. Real people search by what they remember — "the one about dreams", "that space movie". Let's make that work by adding a plot field.

What a searchable field is

A searchable field is any text you want search to look inside. Every list starts with one — name — which is why title search already works. Add more searchable fields and search looks across all of them at once, matching and ranking on every word. For movies, the obvious one is the plot: add it, and "dreams" finds Inception even though that word isn't in the title.

Add the plot field

Open the movies list, choose Fields, then Add Searchable Field.

The Fields menu open, showing Add Searchable Field

Name it plot and add it. That's the whole change — the field is live immediately.

The Add Searchable Field dialog with the name 'plot'

Adding a field doesn't disturb anything you already have. Your existing films are still there; they just have an empty plot until you fill it in. (Because adding a field is safe like this, it does not create a new API version — more on that on the Versioning page.)

Fill in the plots

Open a film with Edit and you'll see the new plot box. Add a sentence describing the film and save.

Editing Inception to add its plot text

Do that for a few films and the list shows the plot alongside each name:

The movies list now showing a populated plot column

Search across both fields

Search now looks in the name and the plot together. A visitor typing dream finds Inception through its plot, even though the word isn't in the title:

GET https://api.searchstack.dev/search/Demo/movies/1?query=dream
X-API-Key: {your key}

The custom fields you added ride along in each result under fields:

{
  "results": [
    {
      "name": "Inception",
      "fields": {
        "plot": "A thief who enters people's dreams to steal secrets is hired to plant an idea instead."
      }
    }
  ],
  "count": 1,
  "total_count": 1
}

Add as many searchable fields as make sense for your data — a tagline, a director, a list of actors. Everything you make searchable becomes another way for a visitor to find the right film. Next we'll add a field of a different kind: one for filtering rather than searching.

Every field type and what search can do with each is covered in the Fields reference.

Next — Facets »
Let visitors filter by genre and year.
Top