Skip to main content
  • Type: string
  • Default: ""
  • Scope: search

Usage

  • Build the similarQuery from relevant object metadata, such as tags, categories, or keywords.
  • This query isn’t generated automatically. You must select meaningful terms manually. For example, a similarQuery for a movie could include its genre, key actors, and tags, such as: Romance Comedy Gordon-Levitt NY.
When specified, this parameter changes the search behavior:
  • Sets queryType to prefixNone—turns off prefix matching.
  • Enables removeStopWords—removes common stop words like “the”, “a”, or “an”.
  • Sets Words as the first ranking criterion—results with more exact matches rank higher.
  • Treats all remaining words as optionalWords:
    • Matches any (not all) of the words in the query (OR behavior).
    • Due to the broader match, you should apply filters to narrow the results.
    • Long queries may trigger specific behavior related to optionalWords with four or more words.

Example

Search with similarQuery

The following example demonstrates the construction of a similarQuery from a record for the movie “Fargo”:
{
  "title": "Fargo",
  "year": 1996,
  "director": "Joel Coen",
  "cast": [
    "Frances McDormand",
    "William H. Macy",
    "Steve Buscemi",
    "Peter Stormare",
    "Harve Presnell"
  ],
  "genres": [
    "Comedy",
    "Drama",
    "Crime"
  ],
  "tags": [
    "black-comedy",
    "americana",
    "coen-brothers",
  ]
  "objectID": "97327292",
  "budget": 7000000
}
From this object, use similarQuery to extract words from genres, cast, and director as a long query string. This search returns many results because all words are optional. To ensure you get the best results, add a filter on release dates within five years of Fargo’s: filter = “year:1991 TO 2001”

Current API clients

var response = await client.SearchSingleIndexAsync<Hit>(
  "ALGOLIA_INDEX_NAME",
  new SearchParams(new SearchParamsObject { Query = "shirt" })
);
index.Search(new Query("")
{
    SimilarQuery = "Comedy Drama Crime McDormand Macy Buscemi Stormare Presnell Coen",
    Filter = "year:1991 TO 2001"
});
I