Use Meilisearch to index content in a text-heavy website. Covers installing Meilisearch, configuring a text scraper, and creating a simple front end.
html
tag).
Here is an example of a basic configuration file:
index_uid
field is the index identifier in your Meilisearch instance in which your website content is stored. The scraping tool will create a new index if it does not exist.
The docs-content
class is the main container of the textual content in this example. Most of the time, this tag is a <main>
or an <article>
HTML element.
lvlX
selectors should use the standard title tags like h1
, h2
, h3
, etc. You can also use static classes. Set a unique id
or name
attribute to these elements.
All searchable lvl
elements outside this main documentation container (for instance, in a sidebar) must be global
selectors. They will be globally picked up and injected to every document built from your page.
If you use VuePress for your documentation, you can check out the configuration file we use in production.
In our case, the main container is theme-default-content
and the selector titles and subtitles are h1
, h2
…
<absolute-path-to-your-config-file>
should be the absolute path of your configuration file defined at the previous step.
The API key should have the permissions to add documents into your Meilisearch instance. In a production environment, we recommend providing the Default Admin API Key
as it has enough permissions to perform such requests.
More about Meilisearch security.
config.js
file:
hostUrl
and the apiKey
fields are the credentials of the Meilisearch instance. Following on from this tutorial, they are respectively MEILISEARCH_URL
and MASTER_KEY
.
indexUid
is the index identifier in your Meilisearch instance in which your website content is stored. It has been defined in the config file.
These three fields are mandatory, but more optional fields are available to customize your search bar.
Default Search API Key
, in a production environment.
Read more about Meilisearch security.hostUrl
and the apiKey
fields are the credentials of the Meilisearch instance. Following on from this tutorial, they are respectively MEILISEARCH_URL
and MASTER_KEY
.
indexUid
is the index identifier in your Meilisearch instance in which your website content is stored. It has been defined in the config file.
inputSelector
is the id
attribute of the HTML search input tag.
Default Search API Key
in a production environment, which is enough to perform search requests.Read more about Meilisearch security.