logo

English

Autocomplete



Notice !

Results are cached for 10 minutes and changes (like updating a document) will not be applied for the same query until 10 minutes pass.
The autocomplete method accepts three parameters:
lableb.autocomplete(collection, queryOptions, [handler])
  1. collection: documents collection name.
  2. queryOptions: search query parameters.
  3. handler: name of the autocomplete handler, this field is OPTIONAL and defaults to suggest.
To find more information about autocomplete configuration and handler Click here.
Example:
lableb
  .autocomplete('collection name', { q: 'query' }, 'suggest')
  .then(response => {
    console.log(response);
  })
  .catch(e => {
    console.log(e.response);
  });

Example response:
{
  suggestions: [
    {
      phrase: 'posts on query',
      suggestion_type: 'filter',
      filters: ['meta_sa:"Search"'],
      feedbackUrl: 'https://api-bahuth.lableb.com/.....'
    },
    {
      phrase: 'search queries are awesome',
      suggestion_type: 'navigational',
      url: 'https://mysite.com/posts/search-queries',
      feedbackUrl: 'https://api-bahuth.lableb.com/.....'
    }
  ]
}

Each autocomplete result will have feedbackUrl field which you can perform a GET request on to submit autocomplete feedback.