0.0
No commit activity in last 3 years
No release in over 3 years
An Elasticsearch full text search index generator for Jekyll.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0
~> 3.2.0

Runtime

>= 3.0.0
~> 2.0.1
 Project Readme

JekyllSearch

build gem license

Live demo

See it in action on my blog.

Installation

Add this line to your application's Gemfile:

source 'https://rubygems.org'

group :jekyll_plugins do
  gem 'jekyll_search'
end

or for bleeding edge:

group :jekyll_plugins do
  gem 'jekyll_search', :git => 'https://github.com/choffmeister/jekyll_search.git', :branch => 'develop'
end

And then execute:

$ bundle

Usage

First you need a machine with Elasticsearch installed. Then configure the search plugin by adding the following entries into your Jekyll _config.yml (replace the host entry if needed):

# Search index settings
search:
  host: localhost:9200
  index:
    name: myindex

Now run jekyll index to iterate over all pages and index them with Elasticsearch. With jekyll search my query you can throw some test searches against your freshly created search index. When you plan to integrate a AJAX based search into your Jekyll page, then the following curl example should help to get started (see also here):

curl -XPOST localhost:9200/myindex/section/_search?pretty -d '{
  "query": {
    "match_phrase_prefix": {
      "content": {
        "query": "I SEARCH FOR SOMETHING",
        "slop": 10
      }
    }
  },
  "highlight": {
    "fields": {
      "content": {}
    }
  }
}'
{
  // ...
  "hits": {
    "total": 7,
    "max_score": 0.61569,
    "hits": [
      {
        // ...
        "_score" : 0.61569,
        "_source": {
          "url": "/link-to-page.html#headline-id",
          "title": "The title",
          "content": "The content"
        },
        "highlight": {
          "content": [
            "Some <em>highlighted</em> stuff"
          ]
        }
      }
      // ...
    ]
  }
  // ...
}

Customize search index

If you want to customize how Elasticsearch creates the search index, then provide an additional index.settings property in your _config.yml (see also here):

# Search index settings
search:
  host: localhost:9200
  index:
    name: myindex
    settings:
      mappings:
        page:
          properties:
            url:
              type: string
              analyzer: keyword
            title:
              type: string
              analyzer: english
            content:
              type: string
              analyzer: english
        section:
          properties:
            url:
              type: string
              analyzer: keyword
            title:
              type: string
              analyzer: english
            content:
              type: string
              analyzer: english

Contributing

  1. Fork it ( https://github.com/choffmeister/jekyll_search/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request