logoBooGi

Search

Git Repository Edit on Github
Last update: a month ago by Mateusz FilipowiczReading time: 4 min

BooGi comes with a content search capabilities. It takes care of indexing content during page build time and makes indexed data accessible in Search UI.

Currently BooGi supports only Algolia as a search engine.

//TODO add screenshots

Algolia

Algolia is a SaaSSaaS - Software as a Service Software licensing and delivery model in which software is licensed on a subscription basis and is centrally hosted and managed search engine, offering full-text search, capable of delivering real-time results. Algolia’s powerful API lets you quickly and seamlessly index content and implement search within your websites.

Algolia offers great free tier, which may be sufficient for plenty of pages using BooGi. For more details on Algolia follow its documentation.

What is indexed?

To provide best search experience, following data is indexed:

  • page title
  • page description
  • content excerpt (up to 5000 characters)
  • page path (URL)
  • page internal ID
  • page category (coming soon)

Setting up Algolia

The first step is to create and set up Algolia account. In order to make Algolia working properly with your page, you need following:

  1. Algolia application
  2. Index
  3. Search-only API key for given Index (or whole application), used for searching
  4. Admin API key for given Index (or whole application), used only for building and managing index. It is used only during page build time.

Creating Algolia application

You can create a new application in the My Account section of the dashboard. Then, in the Applications tab, select New application. You can then switch between your applications via the top-left dropdown menu.

After creating application, open it to further configure it. Go to API Keys tab in Application' dashboard and note down Application ID which will be required later on when configuring BooGiBooGi T lulzhe best documentation tool in the space! Check it here..

Creating an index

Go to Indices tab in Application' dashboard to create a new index. Click on New... then Index and provide its name.

Setting up Search and Admin API key

Go to API Keys tab in Application' dashboard to manage API keys.

You can either use Application-scoped API keys or more fine-grained Index-scoped API keys.

Use Index-scoped API keys instead of Application-scoped API keys, because they provide more security by applying least-privilege approach.

Application-scoped API keys

Application-scope keys have either search or admin rights to all indices within application. They may have too broad permissions than required.

They are created by default and accessible in Your API Keys tab.

Index-scoped API keys

Index-scope keys allow setting up more fine-grained permissions to API keys. You can configure them to set certain access rights to certain indices.

Go to All API Keys tab and select New API Key. Set up desired configuration and select proper ACLs:

  • for Search API Key: search scope,
  • for Admin API Key: addObject, deleteObject, browse, settings, editSettings scopes.

Remember to select proper Indices to which API keys will have rights.

Managing environments

There are two main approaches to managing different environments:

  • application per environment
  • index per environment within single application

Follow this guide to decide which approach will fit you better.

If you're on free tier, you would benefit from _application per environment_ approach, because search quota is defined per whole application, thus each application has separate quota.

Setting up BooGi

Do not hardcode values for algoliaAppId, algoliaSearchKey and algoliaAdminKey as they may leak to your source control system and anyone could potentially gain access to your Algolia account! Use environment variables instead. For more details visit this page.

Search configuration is set in config.yaml under features.search key.

PropertyDescriptionRequiredDefault
search.enabledSet to true to enable search.Yestrue
search.indexNameName of the search indexYesdocs
search.algoliaAppIdAlgolia Application ID. It can be found in API Keys section in Algolia dashboard.
Example: AB1CDE2FGH
Yes
search.algoliaSearchKeyAlgolia Search API Key.
More details about Search Key in section above.
Yes
search.algoliaAdminKeyAlgolia Search API Key.
More details about Admin Key in section above.
Yes
search.placeholderPlaceholder text visible on search input.NoSearch...
search.startComponentComponent used in header to initialize search.

Allowed values: input, icon.
When input is used then search input form is shown in header.
When icon is used, just a search icon is shown in header (it is compact option).
Noinput
search.debounceTimeTime in milliseconds between last keystroke and invoking search operation. It is used to minimize number of search operations and improve overall site performance.

Reasonable values are between 250ms and 600ms.
No380
search.snippetLengthNumber of words shown in a details of a single search result.No22
search.hitsPerPageNumber of search results per page.No10
search.showStatsSet to true to show search statistics (results count and search time) in a results sidebar.Notrue
search.pagination.enabledSet to true to enable search results pagination. If disabled, then only one page will be always visible.Notrue
search.pagination.totalPagesMaximum number of search pages.No10
search.pagination.showNextSet to true to show next page button.Notrue
search.pagination.showPreviousSet to true to show previous page button.Notrue

Full configuration example

features:
search:
enabled: true,
indexName: 'myindex',
placeholder: 'Search here...',
startComponent: 'input',
debounceTime: 380,
snippetLength: 22,
hitsPerPage: 10,
showStats: true,
pagination:
enabled: true,
totalPages: 10,
showNext: true,
showPrevious: true

Local Search

Local search capabilities are coming soon...
Previous
Features
Next
Full example