search_flip 2.0.0.beta7 → 2.0.0.beta8
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/.rubocop.yml +2 -0
 - data/.travis.yml +2 -1
 - data/CHANGELOG.md +10 -0
 - data/README.md +30 -30
 - data/UPDATING.md +40 -0
 - data/docker-compose.yml +2 -0
 - data/lib/search_flip/connection.rb +17 -8
 - data/lib/search_flip/index.rb +31 -20
 - data/lib/search_flip/response.rb +1 -1
 - data/lib/search_flip/version.rb +1 -1
 - data/spec/search_flip/connection_spec.rb +19 -2
 - data/spec/search_flip/index_spec.rb +93 -27
 - data/spec/spec_helper.rb +15 -19
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 8f9a9b030a56e1b3688964be50aed6c66cbe367239a7377c37ebc2045180d4ed
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: d1a90f539bf2b63d708bcc415b1fb5fae95d967fd539a73f716e10ef04c86754
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: '08a14b0c86bcf6744c4dfba020959c6c2fe9002a20ae8c2866cbc745cbe7ea002369c954a3441caaaf07d31bdcc4e68e8ab0ad6a52c236d5bb5f994db6643c5e'
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: bd9f9aa18dc818bd1da8a2ce9d70e38abc6919bf359508b4d0344195cff9546964bfcfa30345fd8b7ff28c86746b352e21c78530f2e3e0522d108e1bc5338574
         
     | 
    
        data/.rubocop.yml
    CHANGED
    
    
    
        data/.travis.yml
    CHANGED
    
    | 
         @@ -5,7 +5,8 @@ env: 
     | 
|
| 
       5 
5 
     | 
    
         
             
              - ES_IMAGE=elasticsearch:1
         
     | 
| 
       6 
6 
     | 
    
         
             
              - ES_IMAGE=plainpicture/elasticsearch:2.4.1_delete-by-query
         
     | 
| 
       7 
7 
     | 
    
         
             
              - ES_IMAGE=elasticsearch:5.4
         
     | 
| 
       8 
     | 
    
         
            -
              - ES_IMAGE=docker.elastic.co/elasticsearch/elasticsearch:6. 
     | 
| 
      
 8 
     | 
    
         
            +
              - ES_IMAGE=docker.elastic.co/elasticsearch/elasticsearch:6.7.0
         
     | 
| 
      
 9 
     | 
    
         
            +
              - ES_IMAGE=docker.elastic.co/elasticsearch/elasticsearch:7.0.0
         
     | 
| 
       9 
10 
     | 
    
         
             
            rvm:
         
     | 
| 
       10 
11 
     | 
    
         
             
              - ruby-head
         
     | 
| 
       11 
12 
     | 
    
         
             
            before_install:
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -9,10 +9,20 @@ 
     | 
|
| 
       9 
9 
     | 
    
         
             
            * [BREAKING] Changed `SearchFlip.aliases` to `SearchFlip::Connection#update_aliases`
         
     | 
| 
       10 
10 
     | 
    
         
             
            * [BREAKING] Changed `SearchFlip.msearch` to `SearchFlip::Connection#msearch`
         
     | 
| 
       11 
11 
     | 
    
         
             
            * [BREAKING] Removed `base_url` param from `SearchFlip::Critiera#execute`
         
     | 
| 
      
 12 
     | 
    
         
            +
            * [BREAKING] `SearchFlip::Index.index_name` no longer defaults to `SearchFlip::Index.type_name`
         
     | 
| 
      
 13 
     | 
    
         
            +
            * [BREAKING] No longer include the type name in `SearchFlip::Index.mapping`
         
     | 
| 
       12 
14 
     | 
    
         
             
            * Added `SearchFlip::Connection#get_aliases`
         
     | 
| 
       13 
15 
     | 
    
         
             
            * Added `SearchFlip::Connection#get_indices`
         
     | 
| 
       14 
16 
     | 
    
         
             
            * Added `SearchFlip::Connection#alias_exists?`
         
     | 
| 
       15 
17 
     | 
    
         
             
            * Added `SearchFlip::Index#with_settings` and `SearchFlip::Criteria#with_settings`
         
     | 
| 
      
 18 
     | 
    
         
            +
            * Added `SearchFlip::Aggregation#merge`
         
     | 
| 
      
 19 
     | 
    
         
            +
            * Added `bulk_max_mb` config and option
         
     | 
| 
      
 20 
     | 
    
         
            +
            * Added `SearchFlip::Index.analyze`
         
     | 
| 
      
 21 
     | 
    
         
            +
            * Added `SearchFlip::Criteria#preference`
         
     | 
| 
      
 22 
     | 
    
         
            +
            * Added `SearchFlip::Criteria#search_type`
         
     | 
| 
      
 23 
     | 
    
         
            +
            * Added `SearchFlip::Criteria#routing`
         
     | 
| 
      
 24 
     | 
    
         
            +
            * Added `SearchFlip::Index.open_index` and `SearchFlip::Index.close_index`
         
     | 
| 
      
 25 
     | 
    
         
            +
            * Added `SearchFlip::Index.mget`
         
     | 
| 
       16 
26 
     | 
    
         | 
| 
       17 
27 
     | 
    
         
             
            ## v1.1.0
         
     | 
| 
       18 
28 
     | 
    
         | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -9,7 +9,7 @@ 
     | 
|
| 
       9 
9 
     | 
    
         
             
            Using SearchFlip it is dead-simple to create index classes that correspond to
         
     | 
| 
       10 
10 
     | 
    
         
             
            [ElasticSearch](https://www.elastic.co/) indices and to manipulate, query and
         
     | 
| 
       11 
11 
     | 
    
         
             
            aggregate these indices using a chainable, concise, yet powerful DSL. Finally,
         
     | 
| 
       12 
     | 
    
         
            -
            SearchFlip supports ElasticSearch 1.x, 2.x, 5.x, 6.x. Check section
         
     | 
| 
      
 12 
     | 
    
         
            +
            SearchFlip supports ElasticSearch 1.x, 2.x, 5.x, 6.x, 7.x. Check section
         
     | 
| 
       13 
13 
     | 
    
         
             
            [Feature Support](#feature-support) for version dependent features.
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
            ```ruby
         
     | 
| 
         @@ -51,6 +51,9 @@ CommentIndex.where(available: true).search("hello world").sort(id: "desc").aggre 
     | 
|
| 
       51 
51 
     | 
    
         | 
| 
       52 
52 
     | 
    
         
             
            ```
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
      
 54 
     | 
    
         
            +
            Finally, SearchFlip comes with a minimal set of dependencies (http-rb, hashie
         
     | 
| 
      
 55 
     | 
    
         
            +
            and oj only).
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
       54 
57 
     | 
    
         
             
            ## Reference Docs
         
     | 
| 
       55 
58 
     | 
    
         | 
| 
       56 
59 
     | 
    
         
             
            SearchFlip has a great documentation.
         
     | 
| 
         @@ -89,10 +92,10 @@ Available config options are: 
     | 
|
| 
       89 
92 
     | 
    
         | 
| 
       90 
93 
     | 
    
         
             
            * `index_prefix` to have a prefix added to your index names automatically. This
         
     | 
| 
       91 
94 
     | 
    
         
             
              can be useful to separate the indices of e.g. testing and development environments.
         
     | 
| 
       92 
     | 
    
         
            -
            * `base_url` to tell  
     | 
| 
      
 95 
     | 
    
         
            +
            * `base_url` to tell SearchFlip how to connect to your cluster
         
     | 
| 
       93 
96 
     | 
    
         
             
            * `bulk_limit` a global limit for bulk requests
         
     | 
| 
       94 
97 
     | 
    
         
             
            * `bulk_max_mb` a global limit for the payload of bulk requests
         
     | 
| 
       95 
     | 
    
         
            -
            * `auto_refresh` tells  
     | 
| 
      
 98 
     | 
    
         
            +
            * `auto_refresh` tells SearchFlip to automatically refresh an index after
         
     | 
| 
       96 
99 
     | 
    
         
             
              import, index, delete, etc operations. This is e.g. usuful for testing, etc.
         
     | 
| 
       97 
100 
     | 
    
         
             
              Defaults to false.
         
     | 
| 
       98 
101 
     | 
    
         | 
| 
         @@ -106,14 +109,14 @@ class CommentIndex 
     | 
|
| 
       106 
109 
     | 
    
         
             
            end
         
     | 
| 
       107 
110 
     | 
    
         
             
            ```
         
     | 
| 
       108 
111 
     | 
    
         | 
| 
       109 
     | 
    
         
            -
            Then tell the Index about the  
     | 
| 
      
 112 
     | 
    
         
            +
            Then tell the Index about the index name, the correspoding model and how to
         
     | 
| 
       110 
113 
     | 
    
         
             
            serialize the model for indexing.
         
     | 
| 
       111 
114 
     | 
    
         | 
| 
       112 
115 
     | 
    
         
             
            ```ruby
         
     | 
| 
       113 
116 
     | 
    
         
             
            class CommentIndex
         
     | 
| 
       114 
117 
     | 
    
         
             
              include SearchFlip::Index
         
     | 
| 
       115 
118 
     | 
    
         | 
| 
       116 
     | 
    
         
            -
              def self. 
     | 
| 
      
 119 
     | 
    
         
            +
              def self.index_name
         
     | 
| 
       117 
120 
     | 
    
         
             
                "comments"
         
     | 
| 
       118 
121 
     | 
    
         
             
              end
         
     | 
| 
       119 
122 
     | 
    
         | 
| 
         @@ -132,42 +135,37 @@ class CommentIndex 
     | 
|
| 
       132 
135 
     | 
    
         
             
            end
         
     | 
| 
       133 
136 
     | 
    
         
             
            ```
         
     | 
| 
       134 
137 
     | 
    
         | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
            `#index`, etc. This can be used to preload associations that are used when
         
     | 
| 
       138 
     | 
    
         
            -
            serializing records or to restrict the records you want to index.
         
     | 
| 
      
 138 
     | 
    
         
            +
            Optionally, you can specify a custom `type_name`, but note that starting with
         
     | 
| 
      
 139 
     | 
    
         
            +
            Elasticsearch 7, types are deprecated.
         
     | 
| 
       139 
140 
     | 
    
         | 
| 
       140 
141 
     | 
    
         
             
            ```ruby
         
     | 
| 
       141 
142 
     | 
    
         
             
            class CommentIndex
         
     | 
| 
       142 
143 
     | 
    
         
             
              # ...
         
     | 
| 
       143 
144 
     | 
    
         | 
| 
       144 
     | 
    
         
            -
              def self. 
     | 
| 
       145 
     | 
    
         
            -
                 
     | 
| 
      
 145 
     | 
    
         
            +
              def self.type_name
         
     | 
| 
      
 146 
     | 
    
         
            +
                "comment"
         
     | 
| 
       146 
147 
     | 
    
         
             
              end
         
     | 
| 
       147 
148 
     | 
    
         
             
            end
         
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
            CommentIndex.import(Comment.all) # => CommentIndex.import(Comment.all.preload(:user))
         
     | 
| 
       150 
149 
     | 
    
         
             
            ```
         
     | 
| 
       151 
150 
     | 
    
         | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
            Simply supply a custom `index_name`.
         
     | 
| 
      
 151 
     | 
    
         
            +
            You can additionally specify an `index_scope` which will automatically be
         
     | 
| 
      
 152 
     | 
    
         
            +
            applied to scopes, eg. ActiveRecord::Relation objects, passed to `#import`,
         
     | 
| 
      
 153 
     | 
    
         
            +
            `#index`, etc. This can be used to preload associations that are used when
         
     | 
| 
      
 154 
     | 
    
         
            +
            serializing records or to restrict the records you want to index.
         
     | 
| 
       157 
155 
     | 
    
         | 
| 
       158 
156 
     | 
    
         
             
            ```ruby
         
     | 
| 
       159 
157 
     | 
    
         
             
            class CommentIndex
         
     | 
| 
       160 
158 
     | 
    
         
             
              # ...
         
     | 
| 
       161 
159 
     | 
    
         | 
| 
       162 
     | 
    
         
            -
              def self. 
     | 
| 
       163 
     | 
    
         
            -
                 
     | 
| 
      
 160 
     | 
    
         
            +
              def self.index_scope(scope)
         
     | 
| 
      
 161 
     | 
    
         
            +
                scope.preload(:user)
         
     | 
| 
       164 
162 
     | 
    
         
             
              end
         
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
              # ...
         
     | 
| 
       167 
163 
     | 
    
         
             
            end
         
     | 
| 
      
 164 
     | 
    
         
            +
             
     | 
| 
      
 165 
     | 
    
         
            +
            CommentIndex.import(Comment.all) # => CommentIndex.import(Comment.all.preload(:user))
         
     | 
| 
       168 
166 
     | 
    
         
             
            ```
         
     | 
| 
       169 
167 
     | 
    
         | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
      
 168 
     | 
    
         
            +
            To specify a custom mapping:
         
     | 
| 
       171 
169 
     | 
    
         | 
| 
       172 
170 
     | 
    
         
             
            ```ruby
         
     | 
| 
       173 
171 
     | 
    
         
             
            class CommentIndex
         
     | 
| 
         @@ -175,10 +173,8 @@ class CommentIndex 
     | 
|
| 
       175 
173 
     | 
    
         | 
| 
       176 
174 
     | 
    
         
             
              def self.mapping
         
     | 
| 
       177 
175 
     | 
    
         
             
                {
         
     | 
| 
       178 
     | 
    
         
            -
                   
     | 
| 
       179 
     | 
    
         
            -
                     
     | 
| 
       180 
     | 
    
         
            -
                      # ...
         
     | 
| 
       181 
     | 
    
         
            -
                    }
         
     | 
| 
      
 176 
     | 
    
         
            +
                  properties: {
         
     | 
| 
      
 177 
     | 
    
         
            +
                    # ...
         
     | 
| 
       182 
178 
     | 
    
         
             
                  }
         
     | 
| 
       183 
179 
     | 
    
         
             
                }
         
     | 
| 
       184 
180 
     | 
    
         
             
              end
         
     | 
| 
         @@ -187,7 +183,11 @@ class CommentIndex 
     | 
|
| 
       187 
183 
     | 
    
         
             
            end
         
     | 
| 
       188 
184 
     | 
    
         
             
            ```
         
     | 
| 
       189 
185 
     | 
    
         | 
| 
       190 
     | 
    
         
            -
             
     | 
| 
      
 186 
     | 
    
         
            +
            Please note that you need to specify the mapping without a type name, even for
         
     | 
| 
      
 187 
     | 
    
         
            +
            Elasticsearch versions before 7, as SearchFlip will add the type name
         
     | 
| 
      
 188 
     | 
    
         
            +
            automatically if neccessary.
         
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
      
 190 
     | 
    
         
            +
            To specify index settings:
         
     | 
| 
       191 
191 
     | 
    
         | 
| 
       192 
192 
     | 
    
         
             
            ```ruby
         
     | 
| 
       193 
193 
     | 
    
         
             
            def self.index_settings
         
     | 
| 
         @@ -250,8 +250,8 @@ CommentIndex.match_all.delete 
     | 
|
| 
       250 
250 
     | 
    
         | 
| 
       251 
251 
     | 
    
         
             
            # or delete manually via the bulk API:
         
     | 
| 
       252 
252 
     | 
    
         | 
| 
       253 
     | 
    
         
            -
            CommentIndex. 
     | 
| 
       254 
     | 
    
         
            -
              CommentIndex. 
     | 
| 
      
 253 
     | 
    
         
            +
            CommentIndex.bulk do |indexer|
         
     | 
| 
      
 254 
     | 
    
         
            +
              CommentIndex.match_all.find_each do |record|
         
     | 
| 
       255 
255 
     | 
    
         
             
                indexer.delete record.id
         
     | 
| 
       256 
256 
     | 
    
         
             
              end
         
     | 
| 
       257 
257 
     | 
    
         
             
            end
         
     | 
    
        data/UPDATING.md
    CHANGED
    
    | 
         @@ -3,6 +3,46 @@ 
     | 
|
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            ## Update 1.x to 2.x
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
      
 6 
     | 
    
         
            +
            * **[BREAKING]** No longer include the mapping in `SearchFlip::Index.mapping`
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            1.x:
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 11 
     | 
    
         
            +
            class MyIndex
         
     | 
| 
      
 12 
     | 
    
         
            +
              include SearchFlip::Index
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              # ...
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              def self.mapping
         
     | 
| 
      
 17 
     | 
    
         
            +
                {
         
     | 
| 
      
 18 
     | 
    
         
            +
                  type_name: {
         
     | 
| 
      
 19 
     | 
    
         
            +
                    properties: {
         
     | 
| 
      
 20 
     | 
    
         
            +
                      # ...
         
     | 
| 
      
 21 
     | 
    
         
            +
                    }
         
     | 
| 
      
 22 
     | 
    
         
            +
                  }
         
     | 
| 
      
 23 
     | 
    
         
            +
                }
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
      
 26 
     | 
    
         
            +
            ```
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            2.x:
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 31 
     | 
    
         
            +
            class MyIndex
         
     | 
| 
      
 32 
     | 
    
         
            +
              include SearchFlip::Index
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              # ...
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              def self.mapping
         
     | 
| 
      
 37 
     | 
    
         
            +
                {
         
     | 
| 
      
 38 
     | 
    
         
            +
                  properties: {
         
     | 
| 
      
 39 
     | 
    
         
            +
                    # ...
         
     | 
| 
      
 40 
     | 
    
         
            +
                  }
         
     | 
| 
      
 41 
     | 
    
         
            +
                }
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
            end
         
     | 
| 
      
 44 
     | 
    
         
            +
            ```
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
       6 
46 
     | 
    
         
             
            * **[BREAKING]** Changed `SearchFlip::Index.base_url` to `SearchFlip::Index.connection`
         
     | 
| 
       7 
47 
     | 
    
         | 
| 
       8 
48 
     | 
    
         
             
            1.x:
         
     | 
    
        data/docker-compose.yml
    CHANGED
    
    
| 
         @@ -171,11 +171,12 @@ module SearchFlip 
     | 
|
| 
       171 
171 
     | 
    
         
             
                #
         
     | 
| 
       172 
172 
     | 
    
         
             
                # @param index_name [String] The index name
         
     | 
| 
       173 
173 
     | 
    
         
             
                # @param index_settings [Hash] The index settings
         
     | 
| 
      
 174 
     | 
    
         
            +
                # @param params [Hash] Optional url params
         
     | 
| 
       174 
175 
     | 
    
         
             
                #
         
     | 
| 
       175 
176 
     | 
    
         
             
                # @return [Boolean] Returns true or raises SearchFlip::ResponseError
         
     | 
| 
       176 
177 
     | 
    
         | 
| 
       177 
     | 
    
         
            -
                def create_index(index_name, index_settings = {})
         
     | 
| 
       178 
     | 
    
         
            -
                  http_client.put(index_url(index_name), json: index_settings)
         
     | 
| 
      
 178 
     | 
    
         
            +
                def create_index(index_name, index_settings = {}, params = {})
         
     | 
| 
      
 179 
     | 
    
         
            +
                  http_client.put(index_url(index_name), params: params, json: index_settings)
         
     | 
| 
       179 
180 
     | 
    
         | 
| 
       180 
181 
     | 
    
         
             
                  true
         
     | 
| 
       181 
182 
     | 
    
         
             
                end
         
     | 
| 
         @@ -250,13 +251,17 @@ module SearchFlip 
     | 
|
| 
       250 
251 
     | 
    
         
             
                # SearchFlip::ResponseError in case any errors occur.
         
     | 
| 
       251 
252 
     | 
    
         
             
                #
         
     | 
| 
       252 
253 
     | 
    
         
             
                # @param index_name [String] The index name
         
     | 
| 
       253 
     | 
    
         
            -
                # @param type_name [String] The type name
         
     | 
| 
       254 
254 
     | 
    
         
             
                # @param mapping [Hash] The mapping
         
     | 
| 
      
 255 
     | 
    
         
            +
                # @param type_name [String] The type name. Starting with Elasticsearch 7,
         
     | 
| 
      
 256 
     | 
    
         
            +
                #   the type name is optional.
         
     | 
| 
       255 
257 
     | 
    
         
             
                #
         
     | 
| 
       256 
258 
     | 
    
         
             
                # @return [Boolean] Returns true or raises SearchFlip::ResponseError
         
     | 
| 
       257 
259 
     | 
    
         | 
| 
       258 
     | 
    
         
            -
                def update_mapping(index_name,  
     | 
| 
       259 
     | 
    
         
            -
                   
     | 
| 
      
 260 
     | 
    
         
            +
                def update_mapping(index_name, mapping, type_name: nil)
         
     | 
| 
      
 261 
     | 
    
         
            +
                  url = type_name ? type_url(index_name, type_name) : index_url(index_name)
         
     | 
| 
      
 262 
     | 
    
         
            +
                  params = type_name && version.to_f >= 6.7 ? { include_type_name: true } : {}
         
     | 
| 
      
 263 
     | 
    
         
            +
             
     | 
| 
      
 264 
     | 
    
         
            +
                  http_client.put("#{url}/_mapping", params: params, json: mapping)
         
     | 
| 
       260 
265 
     | 
    
         | 
| 
       261 
266 
     | 
    
         
             
                  true
         
     | 
| 
       262 
267 
     | 
    
         
             
                end
         
     | 
| 
         @@ -265,12 +270,16 @@ module SearchFlip 
     | 
|
| 
       265 
270 
     | 
    
         
             
                # ElasticSearch. Raises SearchFlip::ResponseError in case any errors occur.
         
     | 
| 
       266 
271 
     | 
    
         
             
                #
         
     | 
| 
       267 
272 
     | 
    
         
             
                # @param index_name [String] The index name
         
     | 
| 
       268 
     | 
    
         
            -
                # @param type_name [String] The type name
         
     | 
| 
      
 273 
     | 
    
         
            +
                # @param type_name [String] The type name. Starting with Elasticsearch 7,
         
     | 
| 
      
 274 
     | 
    
         
            +
                #   the type name is optional.
         
     | 
| 
       269 
275 
     | 
    
         
             
                #
         
     | 
| 
       270 
276 
     | 
    
         
             
                # @return [Hash] The current type mapping
         
     | 
| 
       271 
277 
     | 
    
         | 
| 
       272 
     | 
    
         
            -
                def get_mapping(index_name, type_name)
         
     | 
| 
       273 
     | 
    
         
            -
                   
     | 
| 
      
 278 
     | 
    
         
            +
                def get_mapping(index_name, type_name: nil)
         
     | 
| 
      
 279 
     | 
    
         
            +
                  url = type_name ? type_url(index_name, type_name) : index_url(index_name)
         
     | 
| 
      
 280 
     | 
    
         
            +
                  params = type_name && version.to_f >= 6.7 ? { include_type_name: true } : {}
         
     | 
| 
      
 281 
     | 
    
         
            +
             
     | 
| 
      
 282 
     | 
    
         
            +
                  http_client.headers(accept: "application/json").get("#{url}/_mapping", params: params).parse
         
     | 
| 
       274 
283 
     | 
    
         
             
                end
         
     | 
| 
       275 
284 
     | 
    
         | 
| 
       276 
285 
     | 
    
         
             
                # Deletes the specified index from ElasticSearch. Raises
         
     | 
    
        data/lib/search_flip/index.rb
    CHANGED
    
    | 
         @@ -262,11 +262,11 @@ module SearchFlip 
     | 
|
| 
       262 
262 
     | 
    
         
             
                  # @return [String] The name used for the type within the index
         
     | 
| 
       263 
263 
     | 
    
         | 
| 
       264 
264 
     | 
    
         
             
                  def type_name
         
     | 
| 
       265 
     | 
    
         
            -
                     
     | 
| 
      
 265 
     | 
    
         
            +
                    "_doc"
         
     | 
| 
       266 
266 
     | 
    
         
             
                  end
         
     | 
| 
       267 
267 
     | 
    
         | 
| 
       268 
268 
     | 
    
         
             
                  # Returns the base name of the index within ElasticSearch, ie the index
         
     | 
| 
       269 
     | 
    
         
            -
                  # name without prefix. 
     | 
| 
      
 269 
     | 
    
         
            +
                  # name without prefix.
         
     | 
| 
       270 
270 
     | 
    
         
             
                  #
         
     | 
| 
       271 
271 
     | 
    
         
             
                  # @return [String] The base name of the index, ie without prefix
         
     | 
| 
       272 
272 
     | 
    
         | 
| 
         @@ -327,15 +327,10 @@ module SearchFlip 
     | 
|
| 
       327 
327 
     | 
    
         
             
                  # specified. Raises SearchFlip::ResponseError in case any errors
         
     | 
| 
       328 
328 
     | 
    
         
             
                  # occur.
         
     | 
| 
       329 
329 
     | 
    
         
             
                  #
         
     | 
| 
       330 
     | 
    
         
            -
                  # @param include_mapping [Boolean] Whether or not to include the mapping
         
     | 
| 
       331 
     | 
    
         
            -
                  #
         
     | 
| 
       332 
330 
     | 
    
         
             
                  # @return [Boolean] Returns true or false
         
     | 
| 
       333 
331 
     | 
    
         | 
| 
       334 
     | 
    
         
            -
                  def create_index 
     | 
| 
       335 
     | 
    
         
            -
                     
     | 
| 
       336 
     | 
    
         
            -
                    json = json.merge(mappings: mapping) if include_mapping
         
     | 
| 
       337 
     | 
    
         
            -
             
     | 
| 
       338 
     | 
    
         
            -
                    connection.create_index(index_name_with_prefix, json)
         
     | 
| 
      
 332 
     | 
    
         
            +
                  def create_index
         
     | 
| 
      
 333 
     | 
    
         
            +
                    connection.create_index(index_name_with_prefix, index_settings)
         
     | 
| 
       339 
334 
     | 
    
         
             
                  end
         
     | 
| 
       340 
335 
     | 
    
         | 
| 
       341 
336 
     | 
    
         
             
                  # Closes the index within ElasticSearch. Raises SearchFlip::ResponseError
         
     | 
| 
         @@ -373,24 +368,22 @@ module SearchFlip 
     | 
|
| 
       373 
368 
     | 
    
         
             
                    connection.delete_index(index_name_with_prefix)
         
     | 
| 
       374 
369 
     | 
    
         
             
                  end
         
     | 
| 
       375 
370 
     | 
    
         | 
| 
       376 
     | 
    
         
            -
                  # Specifies a type mapping. Override to specify a custom mapping.
         
     | 
| 
      
 371 
     | 
    
         
            +
                  # Specifies a type mapping. Override to specify a custom mapping. Please
         
     | 
| 
      
 372 
     | 
    
         
            +
                  # note that you don't have to include the type name, even for
         
     | 
| 
      
 373 
     | 
    
         
            +
                  # Elasticsearch versions before 7, as SearchFlip automatically adds the
         
     | 
| 
      
 374 
     | 
    
         
            +
                  # type name if neccessary.
         
     | 
| 
       377 
375 
     | 
    
         
             
                  #
         
     | 
| 
       378 
376 
     | 
    
         
             
                  # @example
         
     | 
| 
       379 
377 
     | 
    
         
             
                  #   def self.mapping
         
     | 
| 
       380 
378 
     | 
    
         
             
                  #     {
         
     | 
| 
       381 
     | 
    
         
            -
                  #        
     | 
| 
       382 
     | 
    
         
            -
                  #          
     | 
| 
       383 
     | 
    
         
            -
                  #           enabled: false
         
     | 
| 
       384 
     | 
    
         
            -
                  #         },
         
     | 
| 
       385 
     | 
    
         
            -
                  #         properties: {
         
     | 
| 
       386 
     | 
    
         
            -
                  #           email: { type: "string", analyzer: "custom_analyzer" }
         
     | 
| 
       387 
     | 
    
         
            -
                  #         }
         
     | 
| 
      
 379 
     | 
    
         
            +
                  #       properties: {
         
     | 
| 
      
 380 
     | 
    
         
            +
                  #         email: { type: "string", analyzer: "custom_analyzer" }
         
     | 
| 
       388 
381 
     | 
    
         
             
                  #       }
         
     | 
| 
       389 
382 
     | 
    
         
             
                  #     }
         
     | 
| 
       390 
383 
     | 
    
         
             
                  #   end
         
     | 
| 
       391 
384 
     | 
    
         | 
| 
       392 
385 
     | 
    
         
             
                  def mapping
         
     | 
| 
       393 
     | 
    
         
            -
                    { 
     | 
| 
      
 386 
     | 
    
         
            +
                    {}
         
     | 
| 
       394 
387 
     | 
    
         
             
                  end
         
     | 
| 
       395 
388 
     | 
    
         | 
| 
       396 
389 
     | 
    
         
             
                  # Updates the type mapping within ElasticSearch according to the mapping
         
     | 
| 
         @@ -398,7 +391,11 @@ module SearchFlip 
     | 
|
| 
       398 
391 
     | 
    
         
             
                  # errors occur.
         
     | 
| 
       399 
392 
     | 
    
         | 
| 
       400 
393 
     | 
    
         
             
                  def update_mapping
         
     | 
| 
       401 
     | 
    
         
            -
                     
     | 
| 
      
 394 
     | 
    
         
            +
                    if include_type_name?
         
     | 
| 
      
 395 
     | 
    
         
            +
                      connection.update_mapping(index_name_with_prefix, { type_name => mapping }, type_name: type_name)
         
     | 
| 
      
 396 
     | 
    
         
            +
                    else
         
     | 
| 
      
 397 
     | 
    
         
            +
                      connection.update_mapping(index_name_with_prefix, mapping)
         
     | 
| 
      
 398 
     | 
    
         
            +
                    end
         
     | 
| 
       402 
399 
     | 
    
         
             
                  end
         
     | 
| 
       403 
400 
     | 
    
         | 
| 
       404 
401 
     | 
    
         
             
                  # Retrieves the current type mapping from ElasticSearch. Raises
         
     | 
| 
         @@ -407,7 +404,21 @@ module SearchFlip 
     | 
|
| 
       407 
404 
     | 
    
         
             
                  # @return [Hash] The current type mapping
         
     | 
| 
       408 
405 
     | 
    
         | 
| 
       409 
406 
     | 
    
         
             
                  def get_mapping
         
     | 
| 
       410 
     | 
    
         
            -
                     
     | 
| 
      
 407 
     | 
    
         
            +
                    if include_type_name?
         
     | 
| 
      
 408 
     | 
    
         
            +
                      connection.get_mapping(index_name_with_prefix, type_name: type_name)
         
     | 
| 
      
 409 
     | 
    
         
            +
                    else
         
     | 
| 
      
 410 
     | 
    
         
            +
                      connection.get_mapping(index_name_with_prefix)
         
     | 
| 
      
 411 
     | 
    
         
            +
                    end
         
     | 
| 
      
 412 
     | 
    
         
            +
                  end
         
     | 
| 
      
 413 
     | 
    
         
            +
             
     | 
| 
      
 414 
     | 
    
         
            +
                  # Returns whether or not to include a type name. As types are deprecated
         
     | 
| 
      
 415 
     | 
    
         
            +
                  # in Elasticsearch 7, this method controls whether or not to include the
         
     | 
| 
      
 416 
     | 
    
         
            +
                  # type name. By default, the method returns true for Elasticsearch
         
     | 
| 
      
 417 
     | 
    
         
            +
                  # versions before 7 or if the specified type name for the index is not
         
     | 
| 
      
 418 
     | 
    
         
            +
                  # equal to _doc.
         
     | 
| 
      
 419 
     | 
    
         
            +
             
     | 
| 
      
 420 
     | 
    
         
            +
                  def include_type_name?
         
     | 
| 
      
 421 
     | 
    
         
            +
                    type_name != "_doc" || connection.version.to_i < 7
         
     | 
| 
       411 
422 
     | 
    
         
             
                  end
         
     | 
| 
       412 
423 
     | 
    
         | 
| 
       413 
424 
     | 
    
         
             
                  # Retrieves the document specified by id from ElasticSearch. Raises
         
     | 
    
        data/lib/search_flip/response.rb
    CHANGED
    
    
    
        data/lib/search_flip/version.rb
    CHANGED
    
    
| 
         @@ -199,6 +199,23 @@ RSpec.describe SearchFlip::Connection do 
     | 
|
| 
       199 
199 
     | 
    
         
             
              end
         
     | 
| 
       200 
200 
     | 
    
         | 
| 
       201 
201 
     | 
    
         
             
              describe "#update_mapping" do
         
     | 
| 
      
 202 
     | 
    
         
            +
                if SearchFlip::Connection.new.version.to_i >= 7
         
     | 
| 
      
 203 
     | 
    
         
            +
                  it "updates the mapping of an index without type name" do
         
     | 
| 
      
 204 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 205 
     | 
    
         
            +
                      connection = SearchFlip::Connection.new
         
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
      
 207 
     | 
    
         
            +
                      mapping = { "properties" => { "id" => { "type" => "long" } } }
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
      
 209 
     | 
    
         
            +
                      connection.create_index("index_name")
         
     | 
| 
      
 210 
     | 
    
         
            +
                      connection.update_mapping("index_name", mapping)
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
                      expect(connection.get_mapping("index_name")).to eq("index_name" => { "mappings" => mapping })
         
     | 
| 
      
 213 
     | 
    
         
            +
                    ensure
         
     | 
| 
      
 214 
     | 
    
         
            +
                      connection.delete_index("index_name") if connection.index_exists?("index_name")
         
     | 
| 
      
 215 
     | 
    
         
            +
                    end
         
     | 
| 
      
 216 
     | 
    
         
            +
                  end
         
     | 
| 
      
 217 
     | 
    
         
            +
                end
         
     | 
| 
      
 218 
     | 
    
         
            +
             
     | 
| 
       202 
219 
     | 
    
         
             
                it "updates the mapping of an index" do
         
     | 
| 
       203 
220 
     | 
    
         
             
                  begin
         
     | 
| 
       204 
221 
     | 
    
         
             
                    connection = SearchFlip::Connection.new
         
     | 
| 
         @@ -206,9 +223,9 @@ RSpec.describe SearchFlip::Connection do 
     | 
|
| 
       206 
223 
     | 
    
         
             
                    mapping = { "type_name" => { "properties" => { "id" => { "type" => "long" } } } }
         
     | 
| 
       207 
224 
     | 
    
         | 
| 
       208 
225 
     | 
    
         
             
                    connection.create_index("index_name")
         
     | 
| 
       209 
     | 
    
         
            -
                    connection.update_mapping("index_name", "type_name" 
     | 
| 
      
 226 
     | 
    
         
            +
                    connection.update_mapping("index_name", mapping, type_name: "type_name")
         
     | 
| 
       210 
227 
     | 
    
         | 
| 
       211 
     | 
    
         
            -
                    expect(connection.get_mapping("index_name", "type_name")).to eq("index_name" => { "mappings" => mapping })
         
     | 
| 
      
 228 
     | 
    
         
            +
                    expect(connection.get_mapping("index_name", type_name: "type_name")).to eq("index_name" => { "mappings" => mapping })
         
     | 
| 
       212 
229 
     | 
    
         
             
                  ensure
         
     | 
| 
       213 
230 
     | 
    
         
             
                    connection.delete_index("index_name") if connection.index_exists?("index_name")
         
     | 
| 
       214 
231 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -33,16 +33,16 @@ RSpec.describe SearchFlip::Index do 
     | 
|
| 
       33 
33 
     | 
    
         
             
              end
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
       35 
35 
     | 
    
         
             
              describe ".type_name" do
         
     | 
| 
       36 
     | 
    
         
            -
                it " 
     | 
| 
      
 36 
     | 
    
         
            +
                it "returns _doc by default" do
         
     | 
| 
       37 
37 
     | 
    
         
             
                  klass = Class.new do
         
     | 
| 
       38 
38 
     | 
    
         
             
                    include SearchFlip::Index
         
     | 
| 
       39 
39 
     | 
    
         
             
                  end
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
                  expect 
     | 
| 
      
 41 
     | 
    
         
            +
                  expect(klass.type_name).to eq("_doc")
         
     | 
| 
       42 
42 
     | 
    
         
             
                end
         
     | 
| 
       43 
43 
     | 
    
         
             
              end
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
       45 
     | 
    
         
            -
              describe ". 
     | 
| 
      
 45 
     | 
    
         
            +
              describe ".index_name" do
         
     | 
| 
       46 
46 
     | 
    
         
             
                it "raises a SearchFlip::MethodNotImplemented by default" do
         
     | 
| 
       47 
47 
     | 
    
         
             
                  klass = Class.new do
         
     | 
| 
       48 
48 
     | 
    
         
             
                    include SearchFlip::Index
         
     | 
| 
         @@ -61,24 +61,35 @@ RSpec.describe SearchFlip::Index do 
     | 
|
| 
       61 
61 
     | 
    
         
             
                  expect(TestIndex.connection).to have_received(:create_index).with("test", {})
         
     | 
| 
       62 
62 
     | 
    
         
             
                end
         
     | 
| 
       63 
63 
     | 
    
         | 
| 
       64 
     | 
    
         
            -
                it "includes the  
     | 
| 
       65 
     | 
    
         
            -
                   
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
                  allow(TestIndex).to receive(:mapping).and_return(mapping)
         
     | 
| 
      
 64 
     | 
    
         
            +
                it "includes the index settings" do
         
     | 
| 
      
 65 
     | 
    
         
            +
                  allow(TestIndex).to receive(:index_settings).and_return(settings: { number_of_shards: 2 })
         
     | 
| 
       68 
66 
     | 
    
         
             
                  allow(TestIndex.connection).to receive(:create_index).and_call_original
         
     | 
| 
       69 
67 
     | 
    
         | 
| 
       70 
     | 
    
         
            -
                  TestIndex.create_index 
     | 
| 
      
 68 
     | 
    
         
            +
                  TestIndex.create_index
         
     | 
| 
       71 
69 
     | 
    
         | 
| 
       72 
     | 
    
         
            -
                  expect(TestIndex.connection).to have_received(:create_index).with("test",  
     | 
| 
      
 70 
     | 
    
         
            +
                  expect(TestIndex.connection).to have_received(:create_index).with("test", { settings: { number_of_shards: 2 } })
         
     | 
| 
       73 
71 
     | 
    
         
             
                end
         
     | 
| 
      
 72 
     | 
    
         
            +
              end
         
     | 
| 
       74 
73 
     | 
    
         | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
                   
     | 
| 
      
 74 
     | 
    
         
            +
              describe ".include_type_name?" do
         
     | 
| 
      
 75 
     | 
    
         
            +
                it "returns true for Elasticsearch before version 7 and the default type name" do
         
     | 
| 
      
 76 
     | 
    
         
            +
                  klass = Class.new do
         
     | 
| 
      
 77 
     | 
    
         
            +
                    include SearchFlip::Index
         
     | 
| 
      
 78 
     | 
    
         
            +
                  end
         
     | 
| 
       78 
79 
     | 
    
         | 
| 
       79 
     | 
    
         
            -
                   
     | 
| 
      
 80 
     | 
    
         
            +
                  expect(klass.include_type_name?).to eq(klass.connection.version.to_i < 7)
         
     | 
| 
      
 81 
     | 
    
         
            +
                end
         
     | 
| 
       80 
82 
     | 
    
         | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
      
 83 
     | 
    
         
            +
                it "returns true if the type name is not equal to _doc" do
         
     | 
| 
      
 84 
     | 
    
         
            +
                  klass = Class.new do
         
     | 
| 
      
 85 
     | 
    
         
            +
                    include SearchFlip::Index
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                    def self.type_name
         
     | 
| 
      
 88 
     | 
    
         
            +
                      "type_name"
         
     | 
| 
      
 89 
     | 
    
         
            +
                    end
         
     | 
| 
      
 90 
     | 
    
         
            +
                  end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                  expect(klass.include_type_name?).to eq(true)
         
     | 
| 
       82 
93 
     | 
    
         
             
                end
         
     | 
| 
       83 
94 
     | 
    
         
             
              end
         
     | 
| 
       84 
95 
     | 
    
         | 
| 
         @@ -160,30 +171,85 @@ RSpec.describe SearchFlip::Index do 
     | 
|
| 
       160 
171 
     | 
    
         
             
              end
         
     | 
| 
       161 
172 
     | 
    
         | 
| 
       162 
173 
     | 
    
         
             
              describe ".update_mapping" do
         
     | 
| 
       163 
     | 
    
         
            -
                 
     | 
| 
       164 
     | 
    
         
            -
                   
     | 
| 
      
 174 
     | 
    
         
            +
                if TestIndex.connection.version.to_i >= 7
         
     | 
| 
      
 175 
     | 
    
         
            +
                  context "without type name" do
         
     | 
| 
      
 176 
     | 
    
         
            +
                    it "delegates to connection" do
         
     | 
| 
      
 177 
     | 
    
         
            +
                      TestIndex.create_index
         
     | 
| 
      
 178 
     | 
    
         
            +
             
     | 
| 
      
 179 
     | 
    
         
            +
                      allow(TestIndex).to receive(:include_type_name?).and_return(false)
         
     | 
| 
       165 
180 
     | 
    
         | 
| 
       166 
     | 
    
         
            -
             
     | 
| 
      
 181 
     | 
    
         
            +
                      mapping = { properties: { id: { type: "long" } } }
         
     | 
| 
       167 
182 
     | 
    
         | 
| 
       168 
     | 
    
         
            -
             
     | 
| 
       169 
     | 
    
         
            -
             
     | 
| 
      
 183 
     | 
    
         
            +
                      allow(TestIndex).to receive(:mapping).and_return(mapping)
         
     | 
| 
      
 184 
     | 
    
         
            +
                      allow(TestIndex.connection).to receive(:update_mapping).and_call_original
         
     | 
| 
       170 
185 
     | 
    
         | 
| 
       171 
     | 
    
         
            -
             
     | 
| 
      
 186 
     | 
    
         
            +
                      TestIndex.update_mapping
         
     | 
| 
       172 
187 
     | 
    
         | 
| 
       173 
     | 
    
         
            -
             
     | 
| 
      
 188 
     | 
    
         
            +
                      expect(TestIndex.connection).to have_received(:update_mapping).with("test", mapping)
         
     | 
| 
      
 189 
     | 
    
         
            +
                    end
         
     | 
| 
      
 190 
     | 
    
         
            +
                  end
         
     | 
| 
      
 191 
     | 
    
         
            +
                end
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
                context "with type name" do
         
     | 
| 
      
 194 
     | 
    
         
            +
                  it "delegates to connection" do
         
     | 
| 
      
 195 
     | 
    
         
            +
                    TestIndex.create_index
         
     | 
| 
      
 196 
     | 
    
         
            +
             
     | 
| 
      
 197 
     | 
    
         
            +
                    mapping = { properties: { id: { type: "long" } } }
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
                    allow(TestIndex).to receive(:mapping).and_return(mapping)
         
     | 
| 
      
 200 
     | 
    
         
            +
                    allow(TestIndex.connection).to receive(:update_mapping).and_call_original
         
     | 
| 
      
 201 
     | 
    
         
            +
             
     | 
| 
      
 202 
     | 
    
         
            +
                    TestIndex.update_mapping
         
     | 
| 
      
 203 
     | 
    
         
            +
             
     | 
| 
      
 204 
     | 
    
         
            +
                    expect(TestIndex.connection).to have_received(:update_mapping).with("test", { "test" => mapping }, type_name: "test")
         
     | 
| 
      
 205 
     | 
    
         
            +
                  end
         
     | 
| 
      
 206 
     | 
    
         
            +
                end
         
     | 
| 
      
 207 
     | 
    
         
            +
              end
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
      
 209 
     | 
    
         
            +
              describe ".mapping" do
         
     | 
| 
      
 210 
     | 
    
         
            +
                it "returns an empty mapping" do
         
     | 
| 
      
 211 
     | 
    
         
            +
                  klass = Class.new do
         
     | 
| 
      
 212 
     | 
    
         
            +
                    include SearchFlip::Index
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
      
 214 
     | 
    
         
            +
                    def self.include_type_name?
         
     | 
| 
      
 215 
     | 
    
         
            +
                      true
         
     | 
| 
      
 216 
     | 
    
         
            +
                    end
         
     | 
| 
      
 217 
     | 
    
         
            +
                  end
         
     | 
| 
      
 218 
     | 
    
         
            +
             
     | 
| 
      
 219 
     | 
    
         
            +
                  expect(klass.mapping).to eq({})
         
     | 
| 
       174 
220 
     | 
    
         
             
                end
         
     | 
| 
       175 
221 
     | 
    
         
             
              end
         
     | 
| 
       176 
222 
     | 
    
         | 
| 
       177 
223 
     | 
    
         
             
              describe ".get_mapping" do
         
     | 
| 
       178 
     | 
    
         
            -
                 
     | 
| 
       179 
     | 
    
         
            -
                   
     | 
| 
       180 
     | 
    
         
            -
             
     | 
| 
      
 224 
     | 
    
         
            +
                if TestIndex.connection.version.to_i >= 7
         
     | 
| 
      
 225 
     | 
    
         
            +
                  context "without type name" do
         
     | 
| 
      
 226 
     | 
    
         
            +
                    it "delegates to connection" do
         
     | 
| 
      
 227 
     | 
    
         
            +
                      allow(TestIndex).to receive(:include_type_name?).and_return(false)
         
     | 
| 
      
 228 
     | 
    
         
            +
                      allow(TestIndex).to receive(:mapping).and_return({})
         
     | 
| 
      
 229 
     | 
    
         
            +
             
     | 
| 
      
 230 
     | 
    
         
            +
                      TestIndex.create_index
         
     | 
| 
      
 231 
     | 
    
         
            +
                      TestIndex.update_mapping
         
     | 
| 
      
 232 
     | 
    
         
            +
             
     | 
| 
      
 233 
     | 
    
         
            +
                      allow(TestIndex.connection).to receive(:get_mapping).and_call_original
         
     | 
| 
      
 234 
     | 
    
         
            +
             
     | 
| 
      
 235 
     | 
    
         
            +
                      TestIndex.get_mapping
         
     | 
| 
       181 
236 
     | 
    
         | 
| 
       182 
     | 
    
         
            -
             
     | 
| 
      
 237 
     | 
    
         
            +
                      expect(TestIndex.connection).to have_received(:get_mapping).with("test")
         
     | 
| 
      
 238 
     | 
    
         
            +
                    end
         
     | 
| 
      
 239 
     | 
    
         
            +
                  end
         
     | 
| 
      
 240 
     | 
    
         
            +
                end
         
     | 
| 
       183 
241 
     | 
    
         | 
| 
       184 
     | 
    
         
            -
             
     | 
| 
      
 242 
     | 
    
         
            +
                context "with type name" do
         
     | 
| 
      
 243 
     | 
    
         
            +
                  it "delegates to connection" do
         
     | 
| 
      
 244 
     | 
    
         
            +
                    TestIndex.create_index
         
     | 
| 
      
 245 
     | 
    
         
            +
                    TestIndex.update_mapping
         
     | 
| 
       185 
246 
     | 
    
         | 
| 
       186 
     | 
    
         
            -
             
     | 
| 
      
 247 
     | 
    
         
            +
                    allow(TestIndex.connection).to receive(:get_mapping).and_call_original
         
     | 
| 
      
 248 
     | 
    
         
            +
             
     | 
| 
      
 249 
     | 
    
         
            +
                    TestIndex.get_mapping
         
     | 
| 
      
 250 
     | 
    
         
            +
             
     | 
| 
      
 251 
     | 
    
         
            +
                    expect(TestIndex.connection).to have_received(:get_mapping).with("test", type_name: "test")
         
     | 
| 
      
 252 
     | 
    
         
            +
                  end
         
     | 
| 
       187 
253 
     | 
    
         
             
                end
         
     | 
| 
       188 
254 
     | 
    
         
             
              end
         
     | 
| 
       189 
255 
     | 
    
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -114,25 +114,23 @@ class ProductIndex 
     | 
|
| 
       114 
114 
     | 
    
         
             
              def self.mapping
         
     | 
| 
       115 
115 
     | 
    
         
             
                if ProductIndex.connection.version.to_i >= 5
         
     | 
| 
       116 
116 
     | 
    
         
             
                  {
         
     | 
| 
       117 
     | 
    
         
            -
                     
     | 
| 
       118 
     | 
    
         
            -
                       
     | 
| 
       119 
     | 
    
         
            -
                         
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
                         
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
                         
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
                          fielddata: true
         
     | 
| 
       130 
     | 
    
         
            -
                        }
         
     | 
| 
      
 117 
     | 
    
         
            +
                    properties: {
         
     | 
| 
      
 118 
     | 
    
         
            +
                      category: {
         
     | 
| 
      
 119 
     | 
    
         
            +
                        type: "text",
         
     | 
| 
      
 120 
     | 
    
         
            +
                        fielddata: true
         
     | 
| 
      
 121 
     | 
    
         
            +
                      },
         
     | 
| 
      
 122 
     | 
    
         
            +
                      title: {
         
     | 
| 
      
 123 
     | 
    
         
            +
                        type: "text",
         
     | 
| 
      
 124 
     | 
    
         
            +
                        fielddata: true
         
     | 
| 
      
 125 
     | 
    
         
            +
                      },
         
     | 
| 
      
 126 
     | 
    
         
            +
                      description: {
         
     | 
| 
      
 127 
     | 
    
         
            +
                        type: "text",
         
     | 
| 
      
 128 
     | 
    
         
            +
                        fielddata: true
         
     | 
| 
       131 
129 
     | 
    
         
             
                      }
         
     | 
| 
       132 
130 
     | 
    
         
             
                    }
         
     | 
| 
       133 
131 
     | 
    
         
             
                  }
         
     | 
| 
       134 
132 
     | 
    
         
             
                else
         
     | 
| 
       135 
     | 
    
         
            -
                  {  
     | 
| 
      
 133 
     | 
    
         
            +
                  { }
         
     | 
| 
       136 
134 
     | 
    
         
             
                end
         
     | 
| 
       137 
135 
     | 
    
         
             
              end
         
     | 
| 
       138 
136 
     | 
    
         | 
| 
         @@ -171,10 +169,8 @@ class TestIndex 
     | 
|
| 
       171 
169 
     | 
    
         | 
| 
       172 
170 
     | 
    
         
             
              def self.mapping
         
     | 
| 
       173 
171 
     | 
    
         
             
                {
         
     | 
| 
       174 
     | 
    
         
            -
                   
     | 
| 
       175 
     | 
    
         
            -
                     
     | 
| 
       176 
     | 
    
         
            -
                      test_field: { type: "date" }
         
     | 
| 
       177 
     | 
    
         
            -
                    }
         
     | 
| 
      
 172 
     | 
    
         
            +
                  properties: {
         
     | 
| 
      
 173 
     | 
    
         
            +
                    test_field: { type: "date" }
         
     | 
| 
       178 
174 
     | 
    
         
             
                  }
         
     | 
| 
       179 
175 
     | 
    
         
             
                }
         
     | 
| 
       180 
176 
     | 
    
         
             
              end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: search_flip
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2.0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.0.0.beta8
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Benjamin Vetter
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2019- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-04-17 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activerecord
         
     |