ej 0.1.1 → 0.1.2
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/ej/commands.rb +9 -1
- data/lib/ej/core.rb +6 -3
- data/lib/ej/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: f0b332b7857e660bfaf5210b79033873d69d664f
         | 
| 4 | 
            +
              data.tar.gz: 9692b219550391e6e63a8c52d96ae633e4d13845
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 82f065af8c92d75f3a0e613466e38cc9216dbe4811610762fc852bac1c528ffa71d16f38fdd21ececb79f917203db3562cd3204f03ba7439dea1f9f6d5e77fb4
         | 
| 7 | 
            +
              data.tar.gz: 85e4ef0bc16bf929609025e84cc0c9725bee86a2efb5eb3a15b8451cc90a383673af6f11fee1665ce78a7103fa9f65ed92bdee7c4d2e99956542779cb735ca6a
         | 
    
        data/lib/ej/commands.rb
    CHANGED
    
    | @@ -69,8 +69,16 @@ module Ej | |
| 69 69 | 
             
                option :query, type: :string, aliases: '-q', default: nil, desc: 'query'
         | 
| 70 70 | 
             
                option :per, type: :numeric, default: nil, desc: 'per'
         | 
| 71 71 | 
             
                option :proc_num, type: :numeric, default: 1, desc: 'proc num for multi thread'
         | 
| 72 | 
            +
                option :from, type: :numeric, default: 0, desc: 'from'
         | 
| 72 73 | 
             
                def copy
         | 
| 73 | 
            -
                  @core.copy( | 
| 74 | 
            +
                  @core.copy(
         | 
| 75 | 
            +
                    options['source'],
         | 
| 76 | 
            +
                    options['dest'],
         | 
| 77 | 
            +
                    options['query'],
         | 
| 78 | 
            +
                    options['per'],
         | 
| 79 | 
            +
                    options['proc_num'],
         | 
| 80 | 
            +
                    options['from']
         | 
| 81 | 
            +
                  )
         | 
| 74 82 | 
             
                end
         | 
| 75 83 |  | 
| 76 84 | 
             
                desc 'dump', 'dump index'
         | 
    
        data/lib/ej/core.rb
    CHANGED
    
    | @@ -42,9 +42,8 @@ module Ej | |
| 42 42 | 
             
                  @client.search index: @index, type: type, body: body
         | 
| 43 43 | 
             
                end
         | 
| 44 44 |  | 
| 45 | 
            -
                def copy(source, dest, query, per_size, proc_num)
         | 
| 45 | 
            +
                def copy(source, dest, query, per_size, proc_num, define_from = 0)
         | 
| 46 46 | 
             
                  per = per_size || DEFAULT_PER
         | 
| 47 | 
            -
                  num = 0
         | 
| 48 47 | 
             
                  logger = Logger.new($stdout)
         | 
| 49 48 | 
             
                  source_client = Elasticsearch::Client.new hosts: source, index: @index
         | 
| 50 49 | 
             
                  dest_client = Elasticsearch::Client.new hosts: dest
         | 
| @@ -55,6 +54,10 @@ module Ej | |
| 55 54 | 
             
                  payloads = ((total/per) + 1).times.to_a
         | 
| 56 55 | 
             
                  Parallel.map(payloads, in_processes: proc_num) do |num|
         | 
| 57 56 | 
             
                    from = num * per
         | 
| 57 | 
            +
                    if from < define_from
         | 
| 58 | 
            +
                      logger.info("skip index (#{num} #{from}-#{from + per})/#{total}")
         | 
| 59 | 
            +
                      next
         | 
| 60 | 
            +
                    end
         | 
| 58 61 | 
             
                    body = { size: per, from: from }
         | 
| 59 62 | 
             
                    body[:query] = { query_string: { query: query } } unless query.nil?
         | 
| 60 63 | 
             
                    data = Hashie::Mash.new(source_client.search index: @index, body: body)
         | 
| @@ -71,7 +74,7 @@ module Ej | |
| 71 74 | 
             
                    end
         | 
| 72 75 | 
             
                    send_with_retry(dest_client, bulk_message)
         | 
| 73 76 |  | 
| 74 | 
            -
                    logger.info("copy complete (#{from}-#{from + docs.size})/#{total}")
         | 
| 77 | 
            +
                    logger.info("copy complete (#{num} #{from}-#{from + docs.size})/#{total}")
         | 
| 75 78 | 
             
                  end
         | 
| 76 79 | 
             
                end
         | 
| 77 80 |  | 
    
        data/lib/ej/version.rb
    CHANGED