jekyll_search 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -14
- data/lib/jekyll_search.rb +5 -5
- data/lib/jekyll_search/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 266d467d948e0f06e9b67d80b4460e39127e57e1
|
4
|
+
data.tar.gz: 42098ce4e4628cf9a2ac55ea3dad5fe5f0871f11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a74dead448ac960a3c32e6546b181fe7561d9c1a57ca6ddcdbca4104378f7dae2d2ef0fe7ff2482adb11d77b0b72709d57bf8a0947c2cce69777931780f8f55
|
7
|
+
data.tar.gz: 4a08fdc4d9474469f2e0a8f1c4cb1c30146ae8bf83dc499498b9bfd4b7e944e4607d1672c08a640880903fc7a1712a8b13517b87e958b25801f1876026cc8369
|
data/README.md
CHANGED
@@ -37,31 +37,35 @@ the following entries into your Jekyll `_config.yml` (replace the `host` entry i
|
|
37
37
|
# Search index settings
|
38
38
|
search:
|
39
39
|
host: localhost:9200
|
40
|
+
index:
|
41
|
+
name: myindex
|
40
42
|
```
|
41
43
|
|
42
44
|
Now run `jekyll index` to iterate over all pages and index them with Elasticsearch. With `jekyll search my query`
|
43
45
|
you can throw some test searches against your freshly created search index.
|
44
46
|
|
45
|
-
If you want to customize how Elasticsearch creates the search index, then provide an additional `index`
|
46
|
-
in your `_config.yml` (see [here][elasticsearch-createindex]:
|
47
|
+
If you want to customize how Elasticsearch creates the search index, then provide an additional `index.settings`
|
48
|
+
property in your `_config.yml` (see [here][elasticsearch-createindex]:
|
47
49
|
|
48
50
|
```yaml
|
49
51
|
# Search index settings
|
50
52
|
search:
|
51
53
|
host: localhost:9200
|
52
54
|
index:
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
55
|
+
name: myindex
|
56
|
+
settings:
|
57
|
+
mappings:
|
58
|
+
page:
|
59
|
+
properties:
|
60
|
+
url:
|
61
|
+
type: string
|
62
|
+
analyzer: keyword
|
63
|
+
title:
|
64
|
+
type: string
|
65
|
+
analyzer: english
|
66
|
+
content:
|
67
|
+
type: string
|
68
|
+
analyzer: english
|
65
69
|
```
|
66
70
|
|
67
71
|
## Contributing
|
data/lib/jekyll_search.rb
CHANGED
@@ -41,7 +41,7 @@ module Jekyll
|
|
41
41
|
content: clean_content(page.content)
|
42
42
|
}
|
43
43
|
|
44
|
-
client.index index: '
|
44
|
+
client.index index: settings['index']['name'], type: 'page', body: body
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -61,11 +61,11 @@ module Jekyll
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def create_index(client, settings)
|
64
|
-
if client.indices.exists index: '
|
65
|
-
client.indices.delete index: '
|
64
|
+
if client.indices.exists index: settings['index']['name']
|
65
|
+
client.indices.delete index: settings['index']['name']
|
66
66
|
end
|
67
67
|
|
68
|
-
client.indices.create index: '
|
68
|
+
client.indices.create index: settings['index']['name'], body: (settings['index']['settings'] or {})
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
@@ -91,7 +91,7 @@ module Jekyll
|
|
91
91
|
settings = site.config['search']
|
92
92
|
|
93
93
|
client = Elasticsearch::Client.new host: settings['host'], log: false
|
94
|
-
result = client.search index: '
|
94
|
+
result = client.search index: settings['index']['name'], body: { query: { match: { content: query } }, highlight: { fields: { content: {} }} }
|
95
95
|
|
96
96
|
puts "Query: #{query}"
|
97
97
|
puts "Total: #{result['hits']['total']}"
|