getAlgoliaResults

Retrieves Algolia results from multiple indices.

Example#

import { getAlgoliaResults } from '@algolia/autocomplete-preset-algolia';
import algoliasearch from 'algoliasearch/lite';
const searchClient = algoliasearch(APP_ID, SEARCH_API_KEY);
getAlgoliaResults({
searchClient,
queries: [
{
indexName: 'instant_search',
query,
params: {
hitsPerPage: 3,
},
},
],
}).then((results) => {
console.log(results);
});

Params#

searchClient#

SearchClient | required

queries#

indexName#

string | required

query#

string | required

params#

SearchParameters | required

Default search parameters:

{
"hitsPerPage": 5,
"highlightPreTag": "__aa-highlight__",
"highlightPostTag": "__/aa-highlight__"
}

Returns#

It returns a promise of the following schema:

{
"hits": [
{
"objectID": "433",
"firstname": "Jimmie",
"lastname": "Barninger",
"_highlightResult": {
"firstname": {
"value": "<em>Jimmie</em>",
"matchLevel": "partial"
},
"lastname": {
"value": "Barninger",
"matchLevel": "none"
}
}
}
],
"page": 0,
"nbHits": 1,
"nbPages": 1,
"hitsPerPage": 20,
"processingTimeMS": 1,
"query": "jimmie paint",
"params": "query=jimmie+paint&attributesToRetrieve=firstname,lastname&hitsPerPage=20"
}