searchyll 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91963903247ac43790bf0f7a55ae0a5cc0f0815d
4
- data.tar.gz: 24c9aece4997afeac573169de55459230036638a
3
+ metadata.gz: 6d90b594ea9e60eb7814951eb5dbd3c5cb4940c1
4
+ data.tar.gz: 9aefa9b3395bf9164930749a55a86131f4ae4cf0
5
5
  SHA512:
6
- metadata.gz: 9e5134e6f59e7dd618b3d5365a48909af64b892d31a9cd4c08fdc3b194face394b7215c9d24ba76a665f494665dc93e7c7e6dc263ca7fce69061a18e30573986
7
- data.tar.gz: 440ed70523bf1c6b341cb038171c93c2dd27ab40e9bc5882bcb1a8f1931ef29de6cfae777b2dcc9103bbe9e75528fc6019d26ff4281fb80156da259ef5d0dbf6
6
+ metadata.gz: 4411dd6cba9f869a4dd0f485fdafd18f6fca7ca55e3d93c472a93acc903f9fdd10e3dc58dc187d8760372cf7682d2efaa495ac172081d5c1311db2e2e5c60a66
7
+ data.tar.gz: eef95afba94a4177bfe5c19c9c37adb97cca12d755ebf83f6a9b742c5ade8f9353a1e200c589383ead6d7862d6da293e157465f478362a9b576e5e0ae8e3e377
@@ -49,7 +49,7 @@ module Searchyll
49
49
 
50
50
  # Prepare our indexing run by creating a new index.
51
51
  def prepare_index
52
- create_index = http_post("/#{elasticsearch_index_name}")
52
+ create_index = http_put("/#{elasticsearch_index_name}")
53
53
  create_index.body = {
54
54
  index: {
55
55
  number_of_shards: configuration.elasticsearch_number_of_shards,
@@ -98,6 +98,7 @@ module Searchyll
98
98
  def http_request(klass, path)
99
99
  req = klass.new(path)
100
100
  req.content_type = 'application/json'
101
+ req['Accept'] = 'application/json'
101
102
  req.basic_auth(uri.user, uri.password)
102
103
  req
103
104
  end
@@ -161,13 +162,16 @@ module Searchyll
161
162
 
162
163
  # delete old indices
163
164
  cleanup_indices = http_delete("/#{old_indices.join(',')}")
165
+ puts %( Old indices: #{old_indices.join(', ')})
164
166
 
165
167
  # run the prepared requests
166
168
  http_start do |http|
167
169
  http.request(refresh)
168
170
  http.request(add_replication)
169
171
  http.request(update_aliases)
170
- http.request(cleanup_indices)
172
+ if !old_indices.empty?
173
+ http.request(cleanup_indices)
174
+ end
171
175
  end
172
176
  end
173
177
 
@@ -1,3 +1,3 @@
1
1
  module Searchyll
2
- VERSION = "0.9.0"
2
+ VERSION = "0.10.0"
3
3
  end
data/lib/searchyll.rb CHANGED
@@ -19,14 +19,33 @@ begin
19
19
  indexers[site].finish
20
20
  end
21
21
 
22
- Jekyll::Hooks.register :posts, :post_render do |post|
22
+ # gets random pages like your home page
23
+ Jekyll::Hooks.register :pages, :post_render do |page|
23
24
  # strip html
24
- nokogiri_doc = Nokogiri::HTML(post.output)
25
+ nokogiri_doc = Nokogiri::HTML(page.output)
25
26
 
26
- indexer = indexers[post.site]
27
- indexer << post.data.merge({
28
- id: post.id,
29
- text: nokogiri_doc.xpath("//article//text()").to_s.gsub(/\s+/, " ")
27
+ puts %( indexing page #{page.url})
28
+
29
+ indexer = indexers[page.site]
30
+ indexer << page.data.merge({
31
+ id: page.name,
32
+ url: page.url,
33
+ text: nokogiri_doc.xpath("//article//text()").to_s.gsub(/\s+/, " ")
34
+ })
35
+ end
36
+
37
+ # gets both posts and collections
38
+ Jekyll::Hooks.register :documents, :post_render do |document|
39
+ # strip html
40
+ nokogiri_doc = Nokogiri::HTML(document.output)
41
+
42
+ puts %( indexing document #{document.url})
43
+
44
+ indexer = indexers[document.site]
45
+ indexer << document.data.merge({
46
+ id: document.id,
47
+ url: document.url,
48
+ text: nokogiri_doc.xpath("//article//text()").to_s.gsub(/\s+/, " ")
30
49
  })
31
50
  end
32
51
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Zadrozny
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2016-05-07 00:00:00.000000000 Z
13
+ date: 2017-06-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  version: '0'
156
156
  requirements: []
157
157
  rubyforge_project:
158
- rubygems_version: 2.5.0
158
+ rubygems_version: 2.5.1
159
159
  signing_key:
160
160
  specification_version: 4
161
161
  summary: A gem to index your Jekyll pages into Elasticsearch.