rawscsi 1.2.0 → 1.3.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/README.md +22 -0
- data/lib/rawscsi/query/compound.rb +13 -1
- data/lib/rawscsi/version.rb +1 -1
- data/spec/lib/rawscsi/query/compound_spec.rb +17 -2
- metadata +23 -23
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 51e8395c614ecbf2c4863ffb244f02df2c99492a
         | 
| 4 | 
            +
              data.tar.gz: 48aa9907d0bc2d5ac3e47206236818d0a29f0293
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 06663b97caefeaad42ecef69e3e2dbcd3851fdb0048720569cc728468a2fb146aa9e158dd229e1ab1a88d4e460892ce23221671346af1a187af7a4f05cecbb09
         | 
| 7 | 
            +
              data.tar.gz: 4c457acc52b35eeb10a650c9751afee156b5087c2d79de5d2bf3e0f3333345e8a4337253394d8ed34806d7167578e8b46e56958ed20c6390c4f01b2532ba5619
         | 
    
        data/README.md
    CHANGED
    
    | @@ -178,6 +178,28 @@ search_songs.search(q: {and: [ {artist: "Cold Play"} ], | |
| 178 178 | 
             
                { title: "Sparks"}]
         | 
| 179 179 |  | 
| 180 180 | 
             
            ```
         | 
| 181 | 
            +
             | 
| 182 | 
            +
            ###### Sort by location
         | 
| 183 | 
            +
            Suppose your search domain has the `latlon` field for geographical location data. You can sort your results
         | 
| 184 | 
            +
            by geographical distance.
         | 
| 185 | 
            +
             | 
| 186 | 
            +
            ```ruby
         | 
| 187 | 
            +
            # returns all theathers playing "The Big Lebowski" sorted by geographical proximity
         | 
| 188 | 
            +
            # where your location is 35.621966 latitude and -120.686706 longitude
         | 
| 189 | 
            +
            movie_theaters.search(q: {films: "The Big Lebowski" },
         | 
| 190 | 
            +
                        sort: "distance asc",
         | 
| 191 | 
            +
                        location: {latitude: 35.621966, longitude: -120.686706}
         | 
| 192 | 
            +
                        )
         | 
| 193 | 
            +
            ```
         | 
| 194 | 
            +
             | 
| 195 | 
            +
            ###### Weighing fields
         | 
| 196 | 
            +
            You can weigh fields in your search request.
         | 
| 197 | 
            +
             | 
| 198 | 
            +
            ```ruby
         | 
| 199 | 
            +
            You care much more about matches in the title, than matches in the plot.
         | 
| 200 | 
            +
            movie_search.search(q: {and: [{title: "title", plot: "plot"}]}, weights: "{fields:['title^2','plot^0.5']}")
         | 
| 201 | 
            +
            ```
         | 
| 202 | 
            +
             | 
| 181 203 | 
             
            The default sort order is Amazon Cloudsearch's rank-score but you can use your own sort as well as a limiting the number of results.
         | 
| 182 204 | 
             
            ```ruby
         | 
| 183 205 | 
             
            search_songs.search(q: {and: [{genres: "Rock"}]}, sort: "rating desc", limit: 100)
         | 
| @@ -11,6 +11,8 @@ module Rawscsi | |
| 11 11 | 
             
                  def build
         | 
| 12 12 | 
             
                    [
         | 
| 13 13 | 
             
                      query,
         | 
| 14 | 
            +
                      distance,
         | 
| 15 | 
            +
                      qoptions,
         | 
| 14 16 | 
             
                      date,
         | 
| 15 17 | 
             
                      sort,
         | 
| 16 18 | 
             
                      start,
         | 
| @@ -46,11 +48,21 @@ module Rawscsi | |
| 46 48 | 
             
                    encode("sort=#{query_hash[:sort]}")
         | 
| 47 49 | 
             
                  end
         | 
| 48 50 |  | 
| 51 | 
            +
                  def distance
         | 
| 52 | 
            +
                    return nil unless location = query_hash[:location]
         | 
| 53 | 
            +
                    "expr.distance=haversin(#{location[:latitude]},#{location[:longitude]},location.latitude,location.longitude)"
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                  def qoptions
         | 
| 57 | 
            +
                    return nil unless weights = query_hash[:weights]
         | 
| 58 | 
            +
                    "q.options=#{CGI.escape(weights)}"
         | 
| 59 | 
            +
                  end
         | 
| 60 | 
            +
             | 
| 49 61 | 
             
                  def start
         | 
| 50 62 | 
             
                    return nil unless query_hash[:start]
         | 
| 51 63 | 
             
                    "start=#{query_hash[:start]}"
         | 
| 52 64 | 
             
                  end
         | 
| 53 | 
            -
             | 
| 65 | 
            +
             | 
| 54 66 | 
             
                  def limit
         | 
| 55 67 | 
             
                    return nil unless query_hash[:limit]
         | 
| 56 68 | 
             
                    "size=#{query_hash[:limit]}"
         | 
    
        data/lib/rawscsi/version.rb
    CHANGED
    
    
| @@ -9,11 +9,26 @@ describe Rawscsi::Query::Compound do | |
| 9 9 | 
             
              end
         | 
| 10 10 |  | 
| 11 11 | 
             
              it "constructs a query that looks only at a single field and specifies fields" do
         | 
| 12 | 
            -
                arg = {:q => {:and => [{:title => "star wars"}]}, :fields => [:title, :genres]} | 
| 12 | 
            +
                arg = {:q => {:and => [{:title => "star wars"}]}, :fields => [:title, :genres]}
         | 
| 13 13 | 
             
                str = Rawscsi::Query::Compound.new(arg).build
         | 
| 14 14 | 
             
                expect(str).to eq("q=(and%20title:%27star%20wars%27)&return=title,genres&q.parser=structured")
         | 
| 15 15 | 
             
              end
         | 
| 16 16 |  | 
| 17 | 
            +
              it "constructs a query with distance" do
         | 
| 18 | 
            +
                arg = { :q => { :and => [{:actors => "Arnold"}, {:title => "Terminator"},{:range => "rating:['8',}"}]},
         | 
| 19 | 
            +
                        :fields => [:title],
         | 
| 20 | 
            +
                        :location => {latitude: 35.621966, longitude: -120.686706}
         | 
| 21 | 
            +
                      }
         | 
| 22 | 
            +
                str = Rawscsi::Query::Compound.new(arg).build
         | 
| 23 | 
            +
                expect(str).to eq("q=(and%20actors:%27Arnold%27title:%27Terminator%27rating:%5B%278%27,%7D)&expr.distance=haversin(35.621966,-120.686706,location.latitude,location.longitude)&return=title&q.parser=structured")
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              it "constructs a query with qoptions" do
         | 
| 27 | 
            +
                arg = {:q => {:and => [{:title => "star wars"}]}, :fields => [:title, :genres], weights: "{fields:['title^2','genres^0.1']}"}
         | 
| 28 | 
            +
                str = Rawscsi::Query::Compound.new(arg).build
         | 
| 29 | 
            +
                expect(str).to eq("q=(and%20title:%27star%20wars%27)&q.options=%7Bfields%3A%5B%27title%5E2%27%2C%27genres%5E0.1%27%5D%7D&return=title,genres&q.parser=structured")
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 17 32 | 
             
              it "constructs a query with a numeric range" do
         | 
| 18 33 | 
             
                arg = { :q => { :and => [{:actors => "Arnold"}, {:title => "Terminator"},{:range => "rating:['8',}"}]},
         | 
| 19 34 | 
             
                        :fields => [:title]
         | 
| @@ -95,7 +110,7 @@ describe Rawscsi::Query::Compound do | |
| 95 110 |  | 
| 96 111 | 
             
              it "constructs a combination of conjunction and prefix query" do
         | 
| 97 112 | 
             
                arg = {:q => {:and => [{:genres => "Action"},
         | 
| 98 | 
            -
                                       {:prefix => {:actor => "Stallone"}}]}} | 
| 113 | 
            +
                                       {:prefix => {:actor => "Stallone"}}]}}
         | 
| 99 114 | 
             
                str = Rawscsi::Query::Compound.new(arg).build
         | 
| 100 115 |  | 
| 101 116 | 
             
                expect(str).to eq("q=(and%20genres:%27Action%27(prefix%20field=actor%20%27Stallone%27))&q.parser=structured")
         | 
    
        metadata
    CHANGED
    
    | @@ -1,41 +1,41 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rawscsi
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.3.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Steven Li
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015- | 
| 11 | 
            +
            date: 2015-03-24 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| 15 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 16 | 
             
                requirements:
         | 
| 17 | 
            -
                - - ~>
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 19 | 
             
                    version: '1.3'
         | 
| 20 20 | 
             
              type: :development
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 | 
            -
                - - ~>
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 26 | 
             
                    version: '1.3'
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: rake
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 30 | 
             
                requirements:
         | 
| 31 | 
            -
                - -  | 
| 31 | 
            +
                - - ">="
         | 
| 32 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 33 | 
             
                    version: '0'
         | 
| 34 34 | 
             
              type: :development
         | 
| 35 35 | 
             
              prerelease: false
         | 
| 36 36 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 37 | 
             
                requirements:
         | 
| 38 | 
            -
                - -  | 
| 38 | 
            +
                - - ">="
         | 
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 40 | 
             
                    version: '0'
         | 
| 41 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| @@ -56,70 +56,70 @@ dependencies: | |
| 56 56 | 
             
              name: vcr
         | 
| 57 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 58 | 
             
                requirements:
         | 
| 59 | 
            -
                - -  | 
| 59 | 
            +
                - - ">="
         | 
| 60 60 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 61 | 
             
                    version: '0'
         | 
| 62 62 | 
             
              type: :development
         | 
| 63 63 | 
             
              prerelease: false
         | 
| 64 64 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 65 | 
             
                requirements:
         | 
| 66 | 
            -
                - -  | 
| 66 | 
            +
                - - ">="
         | 
| 67 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 68 68 | 
             
                    version: '0'
         | 
| 69 69 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 70 | 
             
              name: fakeweb
         | 
| 71 71 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 72 | 
             
                requirements:
         | 
| 73 | 
            -
                - -  | 
| 73 | 
            +
                - - ">="
         | 
| 74 74 | 
             
                  - !ruby/object:Gem::Version
         | 
| 75 75 | 
             
                    version: '0'
         | 
| 76 76 | 
             
              type: :development
         | 
| 77 77 | 
             
              prerelease: false
         | 
| 78 78 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 79 | 
             
                requirements:
         | 
| 80 | 
            -
                - -  | 
| 80 | 
            +
                - - ">="
         | 
| 81 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 82 | 
             
                    version: '0'
         | 
| 83 83 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 84 84 | 
             
              name: pry
         | 
| 85 85 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 86 | 
             
                requirements:
         | 
| 87 | 
            -
                - -  | 
| 87 | 
            +
                - - ">="
         | 
| 88 88 | 
             
                  - !ruby/object:Gem::Version
         | 
| 89 89 | 
             
                    version: '0'
         | 
| 90 90 | 
             
              type: :development
         | 
| 91 91 | 
             
              prerelease: false
         | 
| 92 92 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 93 | 
             
                requirements:
         | 
| 94 | 
            -
                - -  | 
| 94 | 
            +
                - - ">="
         | 
| 95 95 | 
             
                  - !ruby/object:Gem::Version
         | 
| 96 96 | 
             
                    version: '0'
         | 
| 97 97 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 98 98 | 
             
              name: activerecord
         | 
| 99 99 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 100 | 
             
                requirements:
         | 
| 101 | 
            -
                - -  | 
| 101 | 
            +
                - - ">"
         | 
| 102 102 | 
             
                  - !ruby/object:Gem::Version
         | 
| 103 103 | 
             
                    version: '2.0'
         | 
| 104 104 | 
             
              type: :development
         | 
| 105 105 | 
             
              prerelease: false
         | 
| 106 106 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 107 | 
             
                requirements:
         | 
| 108 | 
            -
                - -  | 
| 108 | 
            +
                - - ">"
         | 
| 109 109 | 
             
                  - !ruby/object:Gem::Version
         | 
| 110 110 | 
             
                    version: '2.0'
         | 
| 111 111 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 112 112 | 
             
              name: httparty
         | 
| 113 113 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 114 | 
             
                requirements:
         | 
| 115 | 
            -
                - - ~>
         | 
| 115 | 
            +
                - - "~>"
         | 
| 116 116 | 
             
                  - !ruby/object:Gem::Version
         | 
| 117 117 | 
             
                    version: '0.11'
         | 
| 118 118 | 
             
              type: :runtime
         | 
| 119 119 | 
             
              prerelease: false
         | 
| 120 120 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 121 | 
             
                requirements:
         | 
| 122 | 
            -
                - - ~>
         | 
| 122 | 
            +
                - - "~>"
         | 
| 123 123 | 
             
                  - !ruby/object:Gem::Version
         | 
| 124 124 | 
             
                    version: '0.11'
         | 
| 125 125 | 
             
            - !ruby/object:Gem::Dependency
         | 
| @@ -140,14 +140,14 @@ dependencies: | |
| 140 140 | 
             
              name: faraday_middleware
         | 
| 141 141 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 142 142 | 
             
                requirements:
         | 
| 143 | 
            -
                - -  | 
| 143 | 
            +
                - - ">="
         | 
| 144 144 | 
             
                  - !ruby/object:Gem::Version
         | 
| 145 145 | 
             
                    version: '0'
         | 
| 146 146 | 
             
              type: :runtime
         | 
| 147 147 | 
             
              prerelease: false
         | 
| 148 148 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 149 149 | 
             
                requirements:
         | 
| 150 | 
            -
                - -  | 
| 150 | 
            +
                - - ">="
         | 
| 151 151 | 
             
                  - !ruby/object:Gem::Version
         | 
| 152 152 | 
             
                    version: '0'
         | 
| 153 153 | 
             
            description: Ruby Amazon Web Services Cloud Search Interface
         | 
| @@ -157,8 +157,8 @@ executables: [] | |
| 157 157 | 
             
            extensions: []
         | 
| 158 158 | 
             
            extra_rdoc_files: []
         | 
| 159 159 | 
             
            files:
         | 
| 160 | 
            -
            - .gitignore
         | 
| 161 | 
            -
            - .travis.yml
         | 
| 160 | 
            +
            - ".gitignore"
         | 
| 161 | 
            +
            - ".travis.yml"
         | 
| 162 162 | 
             
            - Gemfile
         | 
| 163 163 | 
             
            - LICENSE.txt
         | 
| 164 164 | 
             
            - README.md
         | 
| @@ -213,17 +213,17 @@ require_paths: | |
| 213 213 | 
             
            - lib
         | 
| 214 214 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 215 215 | 
             
              requirements:
         | 
| 216 | 
            -
              - -  | 
| 216 | 
            +
              - - ">="
         | 
| 217 217 | 
             
                - !ruby/object:Gem::Version
         | 
| 218 218 | 
             
                  version: '0'
         | 
| 219 219 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 220 220 | 
             
              requirements:
         | 
| 221 | 
            -
              - -  | 
| 221 | 
            +
              - - ">="
         | 
| 222 222 | 
             
                - !ruby/object:Gem::Version
         | 
| 223 223 | 
             
                  version: '0'
         | 
| 224 224 | 
             
            requirements: []
         | 
| 225 225 | 
             
            rubyforge_project: 
         | 
| 226 | 
            -
            rubygems_version: 2. | 
| 226 | 
            +
            rubygems_version: 2.4.2
         | 
| 227 227 | 
             
            signing_key: 
         | 
| 228 228 | 
             
            specification_version: 4
         | 
| 229 229 | 
             
            summary: Adds service objects to upload and search active record models with AWS Cloud
         |