searchyll 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/searchyll/indexer.rb +6 -2
- data/lib/searchyll/version.rb +1 -1
- data/lib/searchyll.rb +25 -6
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 6d90b594ea9e60eb7814951eb5dbd3c5cb4940c1
         | 
| 4 | 
            +
              data.tar.gz: 9aefa9b3395bf9164930749a55a86131f4ae4cf0
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 4411dd6cba9f869a4dd0f485fdafd18f6fca7ca55e3d93c472a93acc903f9fdd10e3dc58dc187d8760372cf7682d2efaa495ac172081d5c1311db2e2e5c60a66
         | 
| 7 | 
            +
              data.tar.gz: eef95afba94a4177bfe5c19c9c37adb97cca12d755ebf83f6a9b742c5ade8f9353a1e200c589383ead6d7862d6da293e157465f478362a9b576e5e0ae8e3e377
         | 
    
        data/lib/searchyll/indexer.rb
    CHANGED
    
    | @@ -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 =  | 
| 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 | 
            -
                     | 
| 172 | 
            +
                    if !old_indices.empty?
         | 
| 173 | 
            +
                      http.request(cleanup_indices)
         | 
| 174 | 
            +
                    end
         | 
| 171 175 | 
             
                  end
         | 
| 172 176 | 
             
                end
         | 
| 173 177 |  | 
    
        data/lib/searchyll/version.rb
    CHANGED
    
    
    
        data/lib/searchyll.rb
    CHANGED
    
    | @@ -19,14 +19,33 @@ begin | |
| 19 19 | 
             
                indexers[site].finish
         | 
| 20 20 | 
             
              end
         | 
| 21 21 |  | 
| 22 | 
            -
               | 
| 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( | 
| 25 | 
            +
                nokogiri_doc = Nokogiri::HTML(page.output)
         | 
| 25 26 |  | 
| 26 | 
            -
                 | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 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. | 
| 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:  | 
| 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. | 
| 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.
         |