Socket
Book a DemoInstallSign in
Socket

jekyll_search

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jekyll_search

0.0.8
bundlerRubygems
Version published
Maintainers
1
Created
Source

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

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

FAQs

Package last updated on 02 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.