solr4r 0.0.5 → 0.0.6
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/ChangeLog +30 -0
- data/README +1 -1
- data/lib/solr4r/builder.rb +31 -21
- data/lib/solr4r/client/admin.rb +83 -0
- data/lib/solr4r/client/query.rb +93 -0
- data/lib/solr4r/client/update.rb +123 -0
- data/lib/solr4r/client.rb +113 -149
- data/lib/solr4r/document.rb +14 -14
- data/lib/solr4r/endpoints.rb +86 -0
- data/lib/solr4r/logging.rb +5 -3
- data/lib/solr4r/request.rb +10 -38
- data/lib/solr4r/response.rb +19 -8
- data/lib/solr4r/result.rb +2 -2
- data/lib/solr4r/uri_extension.rb +5 -4
- data/lib/solr4r/version.rb +1 -1
- data/lib/solr4r.rb +3 -2
- data/spec/solr4r/builder_spec.rb +50 -30
- data/spec/solr4r/client_spec.rb +93 -0
- data/spec/spec_helper.rb +0 -4
- metadata +37 -12
- data/lib/solr4r/request_extension.rb +0 -44
    
        data/lib/solr4r/uri_extension.rb
    CHANGED
    
    | @@ -7,7 +7,7 @@ | |
| 7 7 | 
             
            #                                                                             #
         | 
| 8 8 | 
             
            # Copyright (C) 2014-2015 Jens Wille                                          #
         | 
| 9 9 | 
             
            #                                                                             #
         | 
| 10 | 
            -
            #  | 
| 10 | 
            +
            # solr4r is free software: you can redistribute it and/or modify it under the #
         | 
| 11 11 | 
             
            # terms of the GNU Affero General Public License as published by the Free     #
         | 
| 12 12 | 
             
            # Software Foundation, either version 3 of the License, or (at your option)   #
         | 
| 13 13 | 
             
            # any later version.                                                          #
         | 
| @@ -55,12 +55,13 @@ module Solr4R | |
| 55 55 |  | 
| 56 56 | 
             
                def query_pairs(key, value, pairs = [])
         | 
| 57 57 | 
             
                  if value.is_a?(Hash)
         | 
| 58 | 
            -
                     | 
| 58 | 
            +
                    kv = value.fetch(vk = :_, true)
         | 
| 59 | 
            +
                    pairs << [key, kv] unless kv.nil?
         | 
| 59 60 |  | 
| 60 61 | 
             
                    value.each { |sub, val|
         | 
| 61 | 
            -
                      query_pairs("#{key}.#{sub}", val, pairs) }
         | 
| 62 | 
            +
                      query_pairs("#{key}.#{sub}", val, pairs) unless sub == vk }
         | 
| 62 63 | 
             
                  else
         | 
| 63 | 
            -
                    Array(value).each { |val| pairs << [key, val] }
         | 
| 64 | 
            +
                    Array(value).each { |val| pairs << [key, val] unless val.nil? }
         | 
| 64 65 | 
             
                  end
         | 
| 65 66 |  | 
| 66 67 | 
             
                  pairs
         | 
    
        data/lib/solr4r/version.rb
    CHANGED
    
    
    
        data/lib/solr4r.rb
    CHANGED
    
    | @@ -5,9 +5,9 @@ | |
| 5 5 | 
             
            #                                                                             #
         | 
| 6 6 | 
             
            # solr4r -- A Ruby client for Apache Solr                                     #
         | 
| 7 7 | 
             
            #                                                                             #
         | 
| 8 | 
            -
            # Copyright (C) 2014 Jens Wille | 
| 8 | 
            +
            # Copyright (C) 2014-2015 Jens Wille                                          #
         | 
| 9 9 | 
             
            #                                                                             #
         | 
| 10 | 
            -
            #  | 
| 10 | 
            +
            # solr4r is free software: you can redistribute it and/or modify it under the #
         | 
| 11 11 | 
             
            # terms of the GNU Affero General Public License as published by the Free     #
         | 
| 12 12 | 
             
            # Software Foundation, either version 3 of the License, or (at your option)   #
         | 
| 13 13 | 
             
            # any later version.                                                          #
         | 
| @@ -40,4 +40,5 @@ require_relative 'solr4r/logging' | |
| 40 40 | 
             
            require_relative 'solr4r/builder'
         | 
| 41 41 | 
             
            require_relative 'solr4r/request'
         | 
| 42 42 | 
             
            require_relative 'solr4r/response'
         | 
| 43 | 
            +
            require_relative 'solr4r/endpoints'
         | 
| 43 44 | 
             
            require_relative 'solr4r/client'
         | 
    
        data/spec/solr4r/builder_spec.rb
    CHANGED
    
    | @@ -1,13 +1,9 @@ | |
| 1 1 | 
             
            describe Solr4R::Builder do
         | 
| 2 2 |  | 
| 3 | 
            -
              before :all do
         | 
| 4 | 
            -
                @builder = Solr4R::Builder.new
         | 
| 5 | 
            -
              end
         | 
| 6 | 
            -
             | 
| 7 3 | 
             
              describe '#add' do
         | 
| 8 4 |  | 
| 9 5 | 
             
                example do
         | 
| 10 | 
            -
                   | 
| 6 | 
            +
                  expect(subject.add(employeeId: '05991', office: 'Bridgewater', skills: %w[Perl Java])).to eq(<<-EOT)
         | 
| 11 7 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 12 8 | 
             
            <add>
         | 
| 13 9 | 
             
              <doc>
         | 
| @@ -21,7 +17,7 @@ describe Solr4R::Builder do | |
| 21 17 | 
             
                end
         | 
| 22 18 |  | 
| 23 19 | 
             
                example do
         | 
| 24 | 
            -
                   | 
| 20 | 
            +
                  expect(subject.add([{ employeeId: '05992', office: 'Blackwater' }, { employeeId: '05993', skills: 'Ruby' }])).to eq(<<-EOT)
         | 
| 25 21 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 26 22 | 
             
            <add>
         | 
| 27 23 | 
             
              <doc>
         | 
| @@ -37,7 +33,7 @@ describe Solr4R::Builder do | |
| 37 33 | 
             
                end
         | 
| 38 34 |  | 
| 39 35 | 
             
                example do
         | 
| 40 | 
            -
                   | 
| 36 | 
            +
                  expect(subject.add([id: 42, text: 'blah'], commitWithin: 23)).to eq(<<-EOT)
         | 
| 41 37 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 42 38 | 
             
            <add commitWithin="23">
         | 
| 43 39 | 
             
              <doc>
         | 
| @@ -49,7 +45,7 @@ describe Solr4R::Builder do | |
| 49 45 | 
             
                end
         | 
| 50 46 |  | 
| 51 47 | 
             
                example do
         | 
| 52 | 
            -
                   | 
| 48 | 
            +
                  expect(subject.add([[{ id: 42, text: 'blah' }, boost: 10.0]])).to eq(<<-EOT)
         | 
| 53 49 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 54 50 | 
             
            <add>
         | 
| 55 51 | 
             
              <doc boost="10.0">
         | 
| @@ -61,7 +57,7 @@ describe Solr4R::Builder do | |
| 61 57 | 
             
                end
         | 
| 62 58 |  | 
| 63 59 | 
             
                example do
         | 
| 64 | 
            -
                   | 
| 60 | 
            +
                  expect(subject.add(id: 42, text: ['blah', boost: 2.0])).to eq(<<-EOT)
         | 
| 65 61 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 66 62 | 
             
            <add>
         | 
| 67 63 | 
             
              <doc>
         | 
| @@ -73,7 +69,7 @@ describe Solr4R::Builder do | |
| 73 69 | 
             
                end
         | 
| 74 70 |  | 
| 75 71 | 
             
                example do
         | 
| 76 | 
            -
                   | 
| 72 | 
            +
                  expect(subject.add([[{ id: 42, text: ['blah', boost: 2.0] }, boost: 10.0]], commitWithin: 23)).to eq(<<-EOT)
         | 
| 77 73 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 78 74 | 
             
            <add commitWithin="23">
         | 
| 79 75 | 
             
              <doc boost="10.0">
         | 
| @@ -85,7 +81,7 @@ describe Solr4R::Builder do | |
| 85 81 | 
             
                end
         | 
| 86 82 |  | 
| 87 83 | 
             
                example do
         | 
| 88 | 
            -
                   | 
| 84 | 
            +
                  expect(subject.add(employeeId: '05991', office: "\fBridgew\ate\r", skills: %w[Perl Java])).to eq(<<-EOT)
         | 
| 89 85 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 90 86 | 
             
            <add>
         | 
| 91 87 | 
             
              <doc>
         | 
| @@ -103,14 +99,14 @@ describe Solr4R::Builder do | |
| 103 99 | 
             
              describe '#commit' do
         | 
| 104 100 |  | 
| 105 101 | 
             
                example do
         | 
| 106 | 
            -
                   | 
| 102 | 
            +
                  expect(subject.commit).to eq(<<-EOT)
         | 
| 107 103 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 108 104 | 
             
            <commit/>
         | 
| 109 105 | 
             
                  EOT
         | 
| 110 106 | 
             
                end
         | 
| 111 107 |  | 
| 112 108 | 
             
                example do
         | 
| 113 | 
            -
                   | 
| 109 | 
            +
                  expect(subject.commit(softCommit: true)).to eq(<<-EOT)
         | 
| 114 110 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 115 111 | 
             
            <commit softCommit="true"/>
         | 
| 116 112 | 
             
                  EOT
         | 
| @@ -121,14 +117,14 @@ describe Solr4R::Builder do | |
| 121 117 | 
             
              describe '#optimize' do
         | 
| 122 118 |  | 
| 123 119 | 
             
                example do
         | 
| 124 | 
            -
                   | 
| 120 | 
            +
                  expect(subject.optimize).to eq(<<-EOT)
         | 
| 125 121 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 126 122 | 
             
            <optimize/>
         | 
| 127 123 | 
             
                  EOT
         | 
| 128 124 | 
             
                end
         | 
| 129 125 |  | 
| 130 126 | 
             
                example do
         | 
| 131 | 
            -
                   | 
| 127 | 
            +
                  expect(subject.optimize(maxSegments: 42)).to eq(<<-EOT)
         | 
| 132 128 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 133 129 | 
             
            <optimize maxSegments="42"/>
         | 
| 134 130 | 
             
                  EOT
         | 
| @@ -139,7 +135,7 @@ describe Solr4R::Builder do | |
| 139 135 | 
             
              describe '#rollback' do
         | 
| 140 136 |  | 
| 141 137 | 
             
                example do
         | 
| 142 | 
            -
                   | 
| 138 | 
            +
                  expect(subject.rollback).to eq(<<-EOT)
         | 
| 143 139 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 144 140 | 
             
            <rollback/>
         | 
| 145 141 | 
             
                  EOT
         | 
| @@ -150,7 +146,7 @@ describe Solr4R::Builder do | |
| 150 146 | 
             
              describe '#delete' do
         | 
| 151 147 |  | 
| 152 148 | 
             
                example do
         | 
| 153 | 
            -
                   | 
| 149 | 
            +
                  expect(subject.delete(id: '05991')).to eq(<<-EOT)
         | 
| 154 150 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 155 151 | 
             
            <delete>
         | 
| 156 152 | 
             
              <id>05991</id>
         | 
| @@ -159,7 +155,7 @@ describe Solr4R::Builder do | |
| 159 155 | 
             
                end
         | 
| 160 156 |  | 
| 161 157 | 
             
                example do
         | 
| 162 | 
            -
                   | 
| 158 | 
            +
                  expect(subject.delete(id: %w[05991 06000])).to eq(<<-EOT)
         | 
| 163 159 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 164 160 | 
             
            <delete>
         | 
| 165 161 | 
             
              <id>05991</id>
         | 
| @@ -169,7 +165,7 @@ describe Solr4R::Builder do | |
| 169 165 | 
             
                end
         | 
| 170 166 |  | 
| 171 167 | 
             
                example do
         | 
| 172 | 
            -
                   | 
| 168 | 
            +
                  expect(subject.delete(query: 'office:Bridgewater')).to eq(<<-EOT)
         | 
| 173 169 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 174 170 | 
             
            <delete>
         | 
| 175 171 | 
             
              <query>office:Bridgewater</query>
         | 
| @@ -178,7 +174,7 @@ describe Solr4R::Builder do | |
| 178 174 | 
             
                end
         | 
| 179 175 |  | 
| 180 176 | 
             
                example do
         | 
| 181 | 
            -
                   | 
| 177 | 
            +
                  expect(subject.delete(query: %w[office:Bridgewater office:Osaka])).to eq(<<-EOT)
         | 
| 182 178 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 183 179 | 
             
            <delete>
         | 
| 184 180 | 
             
              <query>office:Bridgewater</query>
         | 
| @@ -188,39 +184,45 @@ describe Solr4R::Builder do | |
| 188 184 | 
             
                end
         | 
| 189 185 |  | 
| 190 186 | 
             
                example do
         | 
| 191 | 
            -
                   | 
| 187 | 
            +
                  expect(subject.delete(query: { office: 'Bridgewater', skills: 'Perl' })).to eq(<<-EOT)
         | 
| 192 188 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 193 189 | 
             
            <delete>
         | 
| 194 | 
            -
              <query>office:Bridgewater</query>
         | 
| 195 | 
            -
              <query>skills:Perl</query>
         | 
| 190 | 
            +
              <query>office:Bridgewater skills:Perl</query>
         | 
| 196 191 | 
             
            </delete>
         | 
| 197 192 | 
             
                  EOT
         | 
| 198 193 | 
             
                end
         | 
| 199 194 |  | 
| 200 195 | 
             
                example do
         | 
| 201 | 
            -
                   | 
| 196 | 
            +
                  expect(subject.delete(query: { office: %w[Bridgewater Osaka] })).to eq(<<-EOT)
         | 
| 202 197 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 203 198 | 
             
            <delete>
         | 
| 204 | 
            -
              <query>office:Bridgewater</query>
         | 
| 205 | 
            -
             | 
| 199 | 
            +
              <query>office:Bridgewater office:Osaka</query>
         | 
| 200 | 
            +
            </delete>
         | 
| 201 | 
            +
                  EOT
         | 
| 202 | 
            +
                end
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                example do
         | 
| 205 | 
            +
                  expect(subject.delete(query: { office: 'Bridgewater', _: { type: :edismax } })).to eq(<<-EOT)
         | 
| 206 | 
            +
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 207 | 
            +
            <delete>
         | 
| 208 | 
            +
              <query>{!type=edismax}office:Bridgewater</query>
         | 
| 206 209 | 
             
            </delete>
         | 
| 207 210 | 
             
                  EOT
         | 
| 208 211 | 
             
                end
         | 
| 209 212 |  | 
| 210 213 | 
             
                example do
         | 
| 211 | 
            -
                   | 
| 214 | 
            +
                  expect(subject.delete(id: %w[05991 06000], query: { office: %w[Bridgewater Osaka] })).to eq(<<-EOT)
         | 
| 212 215 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 213 216 | 
             
            <delete>
         | 
| 214 217 | 
             
              <id>05991</id>
         | 
| 215 218 | 
             
              <id>06000</id>
         | 
| 216 | 
            -
              <query>office:Bridgewater</query>
         | 
| 217 | 
            -
              <query>office:Osaka</query>
         | 
| 219 | 
            +
              <query>office:Bridgewater office:Osaka</query>
         | 
| 218 220 | 
             
            </delete>
         | 
| 219 221 | 
             
                  EOT
         | 
| 220 222 | 
             
                end
         | 
| 221 223 |  | 
| 222 224 | 
             
                example do
         | 
| 223 | 
            -
                   | 
| 225 | 
            +
                  expect(subject.delete(query: "office:\fBridgew\ate\r")).to eq(<<-EOT)
         | 
| 224 226 | 
             
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 225 227 | 
             
            <delete>
         | 
| 226 228 | 
             
              <query>office:Bridgewte
</query>
         | 
| @@ -228,6 +230,24 @@ describe Solr4R::Builder do | |
| 228 230 | 
             
                  EOT
         | 
| 229 231 | 
             
                end
         | 
| 230 232 |  | 
| 233 | 
            +
                example do
         | 
| 234 | 
            +
                  expect(subject.delete(query: 'office:Bridge&water')).to eq(<<-EOT)
         | 
| 235 | 
            +
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 236 | 
            +
            <delete>
         | 
| 237 | 
            +
              <query>office:Bridge&water</query>
         | 
| 238 | 
            +
            </delete>
         | 
| 239 | 
            +
                  EOT
         | 
| 240 | 
            +
                end
         | 
| 241 | 
            +
             | 
| 242 | 
            +
                example do
         | 
| 243 | 
            +
                  expect(subject.delete(query: { office: 'Bridge&water' })).to eq(<<-EOT)
         | 
| 244 | 
            +
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 245 | 
            +
            <delete>
         | 
| 246 | 
            +
              <query>office:Bridge&water</query>
         | 
| 247 | 
            +
            </delete>
         | 
| 248 | 
            +
                  EOT
         | 
| 249 | 
            +
                end
         | 
| 250 | 
            +
             | 
| 231 251 | 
             
              end
         | 
| 232 252 |  | 
| 233 253 | 
             
            end
         | 
| @@ -0,0 +1,93 @@ | |
| 1 | 
            +
            describe Solr4R::Client do
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              describe '::query_string' do
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                [
         | 
| 6 | 
            +
                  [nil, nil],
         | 
| 7 | 
            +
                  [nil, ''],
         | 
| 8 | 
            +
                  [nil, []],
         | 
| 9 | 
            +
                  [nil, {}],
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  ['title:foo', 'title:foo'],
         | 
| 12 | 
            +
                  ['title:foo%26bar', 'title:foo&bar'],
         | 
| 13 | 
            +
                  ['title:foo&bar', 'title:foo&bar', false],
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  ['title:foo author:bar', 'title:foo author:bar'],
         | 
| 16 | 
            +
                  ['title:foo author:(bar baz)', 'title:foo author:(bar baz)'],
         | 
| 17 | 
            +
                  ['title:foo -author:(bar baz)', 'title:foo -author:(bar baz)'],
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  ['title:foo', %w[title:foo]],
         | 
| 20 | 
            +
                  ['title:foo%26bar', %w[title:foo&bar]],
         | 
| 21 | 
            +
                  ['title:foo&bar', %w[title:foo&bar], false],
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  ['title:foo author:bar', %w[title:foo author:bar]],
         | 
| 24 | 
            +
                  ['title:foo author:bar', ['title:foo', author: 'bar']],
         | 
| 25 | 
            +
                  ['title:foo author:(bar baz)', %w[title:foo author:(bar\ baz)]],
         | 
| 26 | 
            +
                  ['title:foo -author:(bar baz)', %w[title:foo -author:(bar\ baz)]],
         | 
| 27 | 
            +
                  ['title:foo -author%26:(bar baz)', %w[title:foo -author&:(bar\ baz)]],
         | 
| 28 | 
            +
                  ['title:foo -author&:(bar baz)', %w[title:foo -author&:(bar\ baz)], false],
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  ['title:foo', title: 'foo'],
         | 
| 31 | 
            +
                  ['title:foo%26bar', title: 'foo&bar'],
         | 
| 32 | 
            +
                  ['title:foo&bar', { title: 'foo&bar' }, false],
         | 
| 33 | 
            +
                  ['title:foo%26bar%26baz', title: 'foo&bar&baz'],
         | 
| 34 | 
            +
                  ['title:foo&bar&baz', { title: 'foo&bar&baz' }, false],
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  ['title:foo author:bar', title: 'foo', author: 'bar'],
         | 
| 37 | 
            +
                  ['title:foo author:(bar baz)', title: 'foo', author: '(bar baz)'],
         | 
| 38 | 
            +
                  ['title:foo -author:(bar baz)', title: 'foo', '-author' => '(bar baz)'],
         | 
| 39 | 
            +
                  ['title:foo -author%26:(bar baz)', title: 'foo', '-author&' => '(bar baz)'],
         | 
| 40 | 
            +
                  ['title:foo -author&:(bar baz)', { title: 'foo', '-author&' => '(bar baz)' }, false],
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                  ['title:foo author:bar author:baz', title: 'foo', author: %w[bar baz]],
         | 
| 43 | 
            +
                  ['title:foo author:bar%26baz', title: 'foo', author: %w[bar&baz]],
         | 
| 44 | 
            +
                  ['title:foo author:bar&baz', { title: 'foo', author: %w[bar&baz] }, false],
         | 
| 45 | 
            +
                  ['title:foo -author:bar -author:baz', title: 'foo', '-author' => %w[bar baz]],
         | 
| 46 | 
            +
                  ['title:foo -author%26:bar -author%26:baz', title: 'foo', '-author&' => %w[bar baz]],
         | 
| 47 | 
            +
                  ['title:foo -author&:bar -author&:baz', { title: 'foo', '-author&' => %w[bar baz] }, false],
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                  ['{!q.op=AND}title:foo', title: 'foo', _: 'q.op=AND'],
         | 
| 50 | 
            +
                  ['{!q.op=AND}title:foo author:bar', ['title:foo', author: 'bar', _: 'q.op=AND']],
         | 
| 51 | 
            +
                  ['{!q.op=AND df=title}foo', ['foo', _: 'q.op=AND df=title']],
         | 
| 52 | 
            +
                  ['{!q.op=AND df=title}foo', ['foo', _: %w[q.op=AND df=title]]],
         | 
| 53 | 
            +
                  ['{!q.op=AND df=title}foo', ['foo', _: { 'q.op' => 'AND', df: :title }]]
         | 
| 54 | 
            +
                ].each_with_index { |(expected, *args), index|
         | 
| 55 | 
            +
                  example(index) { expect(described_class.query_string(*args)).to eq(expected) }
         | 
| 56 | 
            +
                }
         | 
| 57 | 
            +
             | 
| 58 | 
            +
              end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
              describe '::local_params_string' do
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                [
         | 
| 63 | 
            +
                  [nil, nil],
         | 
| 64 | 
            +
                  [nil, ''],
         | 
| 65 | 
            +
                  [nil, []],
         | 
| 66 | 
            +
                  [nil, {}],
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                  ['{!q.op=AND df=title}', 'q.op=AND df=title'],
         | 
| 69 | 
            +
                  ['{!q.op=AND df=title}', %w[q.op=AND df=title]],
         | 
| 70 | 
            +
                  ['{!q.op=AND df=title}', 'q.op' => 'AND', df: :title],
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                  ['{!type=dismax qf="myfield yourfield"}', 'type=dismax qf="myfield yourfield"'],
         | 
| 73 | 
            +
                  ['{!type=dismax qf="myfield yourfield"}', ['type=dismax', 'qf="myfield yourfield"']],
         | 
| 74 | 
            +
                  ['{!type=dismax qf="myfield yourfield"}', type: :dismax, qf: 'myfield yourfield'],
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                  ['{!type=dismax qf="myfield%26yourfield"}', 'type=dismax qf="myfield&yourfield"'],
         | 
| 77 | 
            +
                  ['{!type=dismax qf="myfield&yourfield"}', 'type=dismax qf="myfield&yourfield"', {}, false],
         | 
| 78 | 
            +
                  ['{!type=dismax qf="myfield%26yourfield"}', ['type=dismax', 'qf="myfield&yourfield"']],
         | 
| 79 | 
            +
                  ['{!type=dismax qf=myfield%26yourfield}', type: :dismax, qf: 'myfield&yourfield'],
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                  ['{!type=mlt qf=$mlt.fl mintf=$mlt.mintf mindf=$mlt.mindf minwl=$mlt.minwl maxwl=$mlt.maxwl}',
         | 
| 82 | 
            +
                   'type=mlt qf=$mlt.fl mintf=$mlt.mintf mindf=$mlt.mindf minwl=$mlt.minwl maxwl=$mlt.maxwl'],
         | 
| 83 | 
            +
                  ['{!type=mlt qf=$mlt.fl mintf=$mlt.mintf mindf=$mlt.mindf minwl=$mlt.minwl maxwl=$mlt.maxwl}',
         | 
| 84 | 
            +
                   %w[type=mlt qf=$mlt.fl mintf=$mlt.mintf mindf=$mlt.mindf minwl=$mlt.minwl maxwl=$mlt.maxwl]],
         | 
| 85 | 
            +
                  ['{!type=mlt qf=$mlt.fl mintf=$mlt.mintf mindf=$mlt.mindf minwl=$mlt.minwl maxwl=$mlt.maxwl}',
         | 
| 86 | 
            +
                   %w[mintf mindf minwl maxwl], type: :mlt, qf: '$mlt.fl']
         | 
| 87 | 
            +
                ].each_with_index { |(expected, *args), index|
         | 
| 88 | 
            +
                  example(index) { expect(described_class.local_params_string(*args)).to eq(expected) }
         | 
| 89 | 
            +
                }
         | 
| 90 | 
            +
             | 
| 91 | 
            +
              end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: solr4r
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.6
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Jens Wille
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015- | 
| 11 | 
            +
            date: 2015-03-18 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: nokogiri
         | 
| @@ -109,15 +109,19 @@ files: | |
| 109 109 | 
             
            - lib/solr4r.rb
         | 
| 110 110 | 
             
            - lib/solr4r/builder.rb
         | 
| 111 111 | 
             
            - lib/solr4r/client.rb
         | 
| 112 | 
            +
            - lib/solr4r/client/admin.rb
         | 
| 113 | 
            +
            - lib/solr4r/client/query.rb
         | 
| 114 | 
            +
            - lib/solr4r/client/update.rb
         | 
| 112 115 | 
             
            - lib/solr4r/document.rb
         | 
| 116 | 
            +
            - lib/solr4r/endpoints.rb
         | 
| 113 117 | 
             
            - lib/solr4r/logging.rb
         | 
| 114 118 | 
             
            - lib/solr4r/request.rb
         | 
| 115 | 
            -
            - lib/solr4r/request_extension.rb
         | 
| 116 119 | 
             
            - lib/solr4r/response.rb
         | 
| 117 120 | 
             
            - lib/solr4r/result.rb
         | 
| 118 121 | 
             
            - lib/solr4r/uri_extension.rb
         | 
| 119 122 | 
             
            - lib/solr4r/version.rb
         | 
| 120 123 | 
             
            - spec/solr4r/builder_spec.rb
         | 
| 124 | 
            +
            - spec/solr4r/client_spec.rb
         | 
| 121 125 | 
             
            - spec/spec_helper.rb
         | 
| 122 126 | 
             
            homepage: http://github.com/blackwinter/solr4r
         | 
| 123 127 | 
             
            licenses:
         | 
| @@ -125,18 +129,39 @@ licenses: | |
| 125 129 | 
             
            metadata: {}
         | 
| 126 130 | 
             
            post_install_message: |2+
         | 
| 127 131 |  | 
| 128 | 
            -
              solr4r-0.0. | 
| 132 | 
            +
              solr4r-0.0.6 [2015-03-18]:
         | 
| 129 133 |  | 
| 130 | 
            -
              *  | 
| 131 | 
            -
              *  | 
| 132 | 
            -
                 | 
| 133 | 
            -
              *  | 
| 134 | 
            -
                 | 
| 135 | 
            -
              *  | 
| 134 | 
            +
              * Extracted Solr4R::Endpoints from Solr4R::Client.
         | 
| 135 | 
            +
              * Extracted Solr4R::Client::Admin, Solr4R::Client::Query and
         | 
| 136 | 
            +
                Solr4R::Client::Update from Solr4R::Client.
         | 
| 137 | 
            +
              * Added core to Solr4R::Client.default_uri and adjusted
         | 
| 138 | 
            +
                Solr4R::Client::DEFAULT_SYSTEM_PATH.
         | 
| 139 | 
            +
              * Added Solr4R::Client::Admin#cores.
         | 
| 140 | 
            +
              * Added Solr4R::Client::Admin#fields.
         | 
| 141 | 
            +
              * Added Solr4R::Client::Admin#analyze_document.
         | 
| 142 | 
            +
              * Added Solr4R::Client::Admin#analyze_field.
         | 
| 143 | 
            +
              * Added Solr4R::Client::Query#json_document.
         | 
| 144 | 
            +
              * Added Solr4R::Client::Query#more_like_this_h (using the {request
         | 
| 145 | 
            +
                handler}[https://cwiki.apache.org/confluence/display/solr/MoreLikeThis]).
         | 
| 146 | 
            +
              * Added Solr4R::Client::Query#more_like_this_q (using the {query
         | 
| 147 | 
            +
                parser}[https://cwiki.apache.org/confluence/display/solr/Other+Parsers#OtherParsers-MoreLikeThisQueryParser]).
         | 
| 148 | 
            +
              * Added support for {local
         | 
| 149 | 
            +
                params}[https://cwiki.apache.org/confluence/display/solr/Local+Parameters+in+Queries]
         | 
| 150 | 
            +
                to Solr4R::Client.query_string.
         | 
| 151 | 
            +
              * Extended Solr4R::RequestUriExtension#query_pairs to skip +nil+ values.
         | 
| 152 | 
            +
              * Extended Solr4R::RequestUriExtension#query_pairs to allow control over
         | 
| 153 | 
            +
                nested key's value (via +:_+).
         | 
| 154 | 
            +
              * Refactored Solr4R::Document#more_like_this to use
         | 
| 155 | 
            +
                Solr4R::Client#more_like_this.
         | 
| 156 | 
            +
              * Refactored Solr4R::Builder#delete to use Solr4R::Client.query_string for
         | 
| 157 | 
            +
                query hashes.
         | 
| 158 | 
            +
              * Refactored Solr4R::Request preparation; dropped
         | 
| 159 | 
            +
                Solr4R::HTTPRequestExtension.
         | 
| 160 | 
            +
              * Refactored Solr4R::Response initialization.
         | 
| 136 161 |  | 
| 137 162 | 
             
            rdoc_options:
         | 
| 138 163 | 
             
            - "--title"
         | 
| 139 | 
            -
            - solr4r Application documentation (v0.0. | 
| 164 | 
            +
            - solr4r Application documentation (v0.0.6)
         | 
| 140 165 | 
             
            - "--charset"
         | 
| 141 166 | 
             
            - UTF-8
         | 
| 142 167 | 
             
            - "--line-numbers"
         | 
| @@ -157,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 157 182 | 
             
                  version: '0'
         | 
| 158 183 | 
             
            requirements: []
         | 
| 159 184 | 
             
            rubyforge_project: 
         | 
| 160 | 
            -
            rubygems_version: 2.4. | 
| 185 | 
            +
            rubygems_version: 2.4.6
         | 
| 161 186 | 
             
            signing_key: 
         | 
| 162 187 | 
             
            specification_version: 4
         | 
| 163 188 | 
             
            summary: A Ruby client for Apache Solr.
         | 
| @@ -1,44 +0,0 @@ | |
| 1 | 
            -
            # encoding: utf-8
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            #--
         | 
| 4 | 
            -
            ###############################################################################
         | 
| 5 | 
            -
            #                                                                             #
         | 
| 6 | 
            -
            # solr4r -- A Ruby client for Apache Solr                                     #
         | 
| 7 | 
            -
            #                                                                             #
         | 
| 8 | 
            -
            # Copyright (C) 2014 Jens Wille                                               #
         | 
| 9 | 
            -
            #                                                                             #
         | 
| 10 | 
            -
            # Mir is free software: you can redistribute it and/or modify it under the    #
         | 
| 11 | 
            -
            # terms of the GNU Affero General Public License as published by the Free     #
         | 
| 12 | 
            -
            # Software Foundation, either version 3 of the License, or (at your option)   #
         | 
| 13 | 
            -
            # any later version.                                                          #
         | 
| 14 | 
            -
            #                                                                             #
         | 
| 15 | 
            -
            # solr4r is distributed in the hope that it will be useful, but WITHOUT ANY   #
         | 
| 16 | 
            -
            # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS   #
         | 
| 17 | 
            -
            # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for     #
         | 
| 18 | 
            -
            # more details.                                                               #
         | 
| 19 | 
            -
            #                                                                             #
         | 
| 20 | 
            -
            # You should have received a copy of the GNU Affero General Public License    #
         | 
| 21 | 
            -
            # along with solr4r. If not, see <http://www.gnu.org/licenses/>.              #
         | 
| 22 | 
            -
            #                                                                             #
         | 
| 23 | 
            -
            ###############################################################################
         | 
| 24 | 
            -
            #++
         | 
| 25 | 
            -
             | 
| 26 | 
            -
            require 'cgi'
         | 
| 27 | 
            -
             | 
| 28 | 
            -
            module Solr4R
         | 
| 29 | 
            -
             | 
| 30 | 
            -
              module HTTPRequestExtension
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                def self.extended(base)
         | 
| 33 | 
            -
                  base.send(:attr_accessor, :params)
         | 
| 34 | 
            -
                end
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                def from_uri(uri)
         | 
| 37 | 
            -
                  req = new(uri)
         | 
| 38 | 
            -
                  req.params = uri.params
         | 
| 39 | 
            -
                  req
         | 
| 40 | 
            -
                end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
              end
         | 
| 43 | 
            -
             | 
| 44 | 
            -
            end
         |