Document indexing in ElasticSearch for Hexo.
Go to file
Jakub Sokołowski 54c58f594f
package.json: upgrade elasticsearch to 16.7.2
Signed-off-by: Jakub Sokołowski <jakub@status.im>
2021-09-29 17:15:21 +02:00
lib refactor by separating into methods 2020-07-27 12:13:43 +02:00
.gitignore upgrade jquery to 3.5.0 2020-04-30 09:37:16 +02:00
LICENSE add MIT license 2018-11-30 15:37:03 +01:00
README.md update README to account for new helpers 2019-01-14 14:42:41 +01:00
index.js splify adding jquery libraries to resulting files 2019-01-12 13:37:23 +01:00
package-lock.json install elasticsearch library as dependency 2018-11-30 15:40:07 +01:00
package.json package.json: upgrade elasticsearch to 16.7.2 2021-09-29 17:15:21 +02:00
yarn.lock package.json: upgrade elasticsearch to 16.7.2 2021-09-29 17:15:21 +02:00

README.md

Description

hexo-algolia is an hexo plugin developed for internal use by Status.im. This is what you get when you install it:

  • A new command, hexo elasticsearch, to index the content of your website.
  • Two helpers:
    • One for configuring destination for queries.
    • One for including a search JS script for handling input.

The hexo algolia command can be run manually on your computer and on a continuous integration system.

Install

npm install --save https://github.com/status-im/hexo-elasticsearch.git

Configuration

The required configuration in _config.yml under elasticsearch keys is:

elasticsearch:
  index: 'dev.status.im'
  esHost: 'search.status.im'
  esPort: 443

And the required HTTP Auth env variables need to be provided to index:

export HEXO_ES_USER='es-user'
export HEXO_ES_PASS='super-secret-password'

Usage

Standard usage for indexing:

hexo elasticsearch

Dry Run:

hexo elasticsearch --dry-run

Delete index before upload:

hexo elasticsearch --delete

Helpers

If you want to start using the search you can use the two included helpers:

  • elasticsearch_config - Adds neccessary script and meta tags with configuration from your _config.yml.
  • elasticsearch_script - Adds the JS script which handles the given target tag to execute the query.

Example

<html>
  <head>
    <meta charset="utf-8">
    <%- elasticsearch_config() %>
  </head>
  <body>
    <input type="text" id="userSearch" placeholder="Search...">
    <%- elasticsearch_script({target: "input#userSearch", size: 6}) %>
  </body>
<html>