21 Nov 2018

Search Overview

Basic Queries

To retrieve results from Algolia, you will need to leverage the Search index method. Querying Algolia involves defining:

  • the index against which you are querying
  • a query string
  • optional parameters

Optional parameters can alter textual relevance behavior at query-time, potentially overriding index-level settings. For example, it’s possible to define stop words or change plurals behavior only for certain queries.

We recommend querying Algolia directly from the end user’s browser, mobile device, or client to ensure optimal performance by reducing latency (and giving you the benefit of offloading your servers!).

Here’s a basic query example:

index.search({
    query: 'query',
    ignorePlurals: true
});

Empty Queries

In some cases, you might not need to pass in a textual query. It’s possible to retrieve results from Algolia by specifying an index and other optional parameters (most likely, a filter). In this way, it’s possible to use Algolia beyond a standard “search results” experience. For example, one common use case is to leverage filtering capabilities to generate category landing pages.

Response Format

If a query is successful, your request will generate a JSON response in return. This response contains both the matching results (“hits”) as well as other information useful for building a full-fledged search experience (for example: facets, highlighting, hits count, and more).

Check out our Building a Search UI Guide for a deeper look into the response’s content.

Out of the Box Relevance

Algolia comes with built in textual relevance that requires very little fine-tuning to work well for the vast majority of use cases. All that is required on your end is to define two main parameters: your searchableAttributes and customRanking. Our Ranking Formula Guide and Relevance Overview Guide dive deeper into these concepts.

Algolia allows you to browse through all objects of an index using the Browse index method. If you need to retrieve all the content of your index (for backup, SEO purposes or for running a script on it), we recommend leveraging browse as opposed to querying, as this method is optimized for speed. Results will be returned ranked by attributes and custom ranking. Additionally, browse supports almost all of the search parameters, meaning you can easily apply filters to retrieve a subset of results. To view code examples, see our exporting your data tutorial.

Try these tutorials

If you want to get started building your search UI, we have a few tutorials you might find helpful:

© Algolia - Privacy Policy