Gleb Bahmutov PRO
JavaScript ninja, image processing expert, software quality fanatic
Algolia Search is Easy
https://lizkeogh.com/2019/07/02/off-the-charts/
+3 degrees Celsius will be the end.
aka "You are always losing customers"
aka "You are always losing customers"
💵
💰
👀
🧑💻
🦸
aka "You are always losing customers"
10-20%
aka "You are always losing customers"
10-20%
What if you converted all first time visitors to paying customers?
aka "You are always losing customers"
10-20%
What if you converted all first time visitors to paying customers?
You would increase your revenue 5 or 10 times!
aka "You are always losing customers"
Why the drop outs?
This tool does not do what I need
It does not work on my platform
Valid reasons
aka "You are always losing customers"
Why the drop outs?
This tool does not do what I need
It does not work on my platform
Valid reasons
This tool does not do what I need (but it does)
Does not work on my platform (but it does work)
Wrong reasons
aka "You are always losing customers"
Why the drop outs?
This tool does not run on my CI
Valid reasons
I don't know how to make this tool work on my CI
Wrong reasons
aka "You are always losing customers"
Why the drop outs?
I cannot afford this tool
Valid reasons
I don't know what value this tool gives me
Wrong reasons
aka "You are always losing customers"
Why the drop outs?
I am happy with this tool, that's enough for me
Valid reasons
I did not know this tool could do that
Wrong reasons
aka "You are always losing customers"
Why the drop outs?
Market fit
Features
Bug fixes
aka "You are always losing customers"
Why the drop outs?
Market fit
Features
Bug fixes
Bad UI
Bad docs
Lack of examples
aka "You are always losing customers"
Why the drop outs?
Market fit
Features
Bug fixes
Bad UI
Bad docs
Lack of examples
Goal: drive the "bad" area to zero
aka "You are always losing customers"
If you stop losing users in red area, you would increase your revenue 2 or 5 times!
Bad UI
Bad docs
Lack of examples
Goal: drive the "bad" area to zero
Bad UI
Bad docs
Lack of examples
Market fit
Features
Bug fixes
Information for every user persona
Is there a way to disable command snapshots?
How to preserve session cookie?
How to check the length of text?
Every question here is a failure of the documentation
Every question here is probably a:
all well-defined questions across chat, support emails, github issues
questions that have answer in your documentation
* 100%
(many things are not documented)
(users cannot find the right documentation)
💥
"show me Hello, World!"
"show me the changelog diff from version X to Y"
"show me a tutorial"
"show me how to do X"
"how do I solve my issue or bug?"
Then add all your documentation to the site reachable from the index
Instead, update the documentation, or create an example, or write a blog post.
Then answer with a link
Should eliminate their own jobs by writing more and more documentation until the users find everything themselves
Hint: look at the search results for "about" query
to add records to the index
(keep private)
to search index from site
(public)
{
"index_name": "scrape-test",
"start_urls": ["https://glebbahmutov.com/triple-tested/"],
"selectors": {
"lvl0": {
"selector": ".site-name",
"global": true
},
"lvl1": ".content__default h1",
"lvl2": ".content__default h2",
"lvl3": ".content__default h3",
"lvl4": ".content__default h4",
"lvl5": ".content__default h5",
"text": ".content__default p, .content__default li"
}
}
Algolia config (JSON)
# when scraping the site, inject secrets as environment variables
# then pass their values into the Docker container using "-e" syntax
# and inject config.json contents as another variable
- name: scrape the site 🧽
env:
APPLICATION_ID: ${{ secrets.APPLICATION_ID }}
API_KEY: ${{ secrets.API_KEY }}
run: |
docker run \
-e APPLICATION_ID -e API_KEY \
-e CONFIG="$(cat config.json)" \
algolia/docsearch-scraper:v1.6.0
use Algolia Docker image
# when scraping the site, inject secrets as environment variables
# then pass their values into the Docker container using "-e" syntax
# and inject config.json contents as another variable
- name: scrape the site 🧽
env:
APPLICATION_ID: ${{ secrets.APPLICATION_ID }}
API_KEY: ${{ secrets.API_KEY }}
run: |
docker run \
-e APPLICATION_ID -e API_KEY \
-e CONFIG="$(cat config.json)" \
algolia/docsearch-scraper:v1.6.0
use Algolia Docker image
module.exports = {
title: 'Triple Tested',
description: 'Example static site',
base: '/triple-tested/',
themeConfig: {
algolia: {
// DANGER 🧨💀: ONLY USE ALGOLIA PUBLIC SEARCH-ONLY API KEY
apiKey: 'a2f5586dd739087cabead4b20ae0c2bc',
indexName: 'scrape-test',
appId: 'XVIJU4G89W'
}
}
}
using built-in VuePress Algolia Widget
blog
examples
{
"index_name": "cypress",
"start_urls": [
{
"url": "https://docs.cypress.io/",
"page_rank": 10
},
{
"url": "https://example.cypress.io/",
"selectors_key": "kitchensink",
"tags": ["example"],
"page_rank": 2
},
{
"url": "https://www.cypress.io/blog/",
"selectors_key": "blog",
"tags": ["blog post"],
"page_rank": 1
}
],
"stop_urls": [
"^https://docs.cypress.io/ja/",
"^https://docs.cypress.io/zh-cn/",
"^https://docs.cypress.io/pt-br/",
"^https://docs.cypress.io/ru/"
],
"selectors_exclude": [],
"selectors": {
"default": {
"lvl0": "article h1.article-title",
"lvl1": "article h1.article-heading",
"lvl2": "article h2.article-heading",
"text": "article .article-content p, article .article-content tr, article .article-content li, article .article-content pre"
},
"blog": {
"lvl0": "article h1",
"lvl1": "article h2",
"text": "article p, article pre"
},
"kitchensink": {
"lvl0": ".container h1",
"lvl1": ".container h4",
"text": ".container p, .container pre"
}
},
"nb_hits": 0,
"min_indexed_level": 2
}
Algolia config (JSON)
2 minutes to scrape, creates ~ 21k records
{
"index_name": "cypress-examples",
"start_urls": ["https://glebbahmutov.com/cypress-examples/"],
"selectors": {
"lvl0": {
"selector": ".site-name",
"global": true
},
"lvl1": ".content__default h1",
"lvl2": ".content__default h2",
"lvl3": ".content__default h3",
"lvl4": ".content__default h4",
"lvl5": ".content__default h5",
"text": ".content__default p, .content__default li, .content__default pre .comment"
}
}
algolia-config.json
{
"index_name": "cypress-examples",
"start_urls": ["https://glebbahmutov.com/cypress-examples/"],
"selectors": {
"lvl0": {
"selector": ".site-name",
"global": true
},
"lvl1": ".content__default h1",
"lvl2": ".content__default h2",
"lvl3": ".content__default h3",
"lvl4": ".content__default h4",
"lvl5": ".content__default h5",
"text": ".content__default p, .content__default li, .content__default pre .comment"
}
}
algolia-config.json
⚠️ free Algolia plans only get weekly emails with such queries
write docs for these searches!
Tweet at me when you get 10x users from a better docs search!
By Gleb Bahmutov
Having a good text search is the key to successful documentation, especially as the number of pages, examples, code recipes, answers, and other user-facing text snippets grow. In this presentation, I will show how to set up the Algolia search index and use it from a static site to make sure your users find _everything_ they are looking for. Video at https://www.youtube.com/watch?v=z_RutLs0W70
JavaScript ninja, image processing expert, software quality fanatic