@@ -28,7 +28,11 @@ def initialize(options = {})
2828
2929    def  version 
3030      @version_mutex . synchronize  do 
31-         @version  ||= http_client . headers ( accept : "application/json" ) . get ( "#{ base_url }  ) . parse [ "version" ] [ "number" ] 
31+         @version  ||= begin 
32+           response  =  http_client . headers ( accept : "application/json" ) . get ( "#{ base_url }  ) 
33+ 
34+           SearchFlip ::JSON . parse ( response . to_s ) [ "version" ] [ "number" ] 
35+         end 
3236      end 
3337    end 
3438
@@ -40,7 +44,9 @@ def version
4044    # @return [Hash] The raw response 
4145
4246    def  cluster_health 
43-       http_client . headers ( accept : "application/json" ) . get ( "#{ base_url }  ) . parse 
47+       response  =  http_client . headers ( accept : "application/json" ) . get ( "#{ base_url }  ) 
48+ 
49+       SearchFlip ::JSON . parse ( response . to_s ) 
4450    end 
4551
4652    # Uses the Elasticsearch Multi Search API to execute multiple search requests 
@@ -71,7 +77,7 @@ def msearch(criterias)
7177          . headers ( accept : "application/json" ,  content_type : "application/x-ndjson" ) 
7278          . post ( "#{ base_url }  ,  body : payload ) 
7379
74-       raw_response . parse [ "responses" ] . map . with_index  do  |response ,  index |
80+       SearchFlip :: JSON . parse ( raw_response . to_s ) [ "responses" ] . map . with_index  do  |response ,  index |
7581        SearchFlip ::Response . new ( criterias [ index ] ,  response ) 
7682      end 
7783    end 
@@ -90,10 +96,11 @@ def msearch(criterias)
9096    # @return [Hash] The raw response 
9197
9298    def  update_aliases ( payload ) 
93-       http_client 
99+       response   =   http_client 
94100        . headers ( accept : "application/json" ,  content_type : "application/json" ) 
95101        . post ( "#{ base_url }  ,  body : SearchFlip ::JSON . generate ( payload ) ) 
96-         . parse 
102+ 
103+       SearchFlip ::JSON . parse ( response . to_s ) 
97104    end 
98105
99106    # Sends an analyze request to Elasticsearch. Raises 
@@ -105,10 +112,11 @@ def update_aliases(payload)
105112    # @return [Hash] The raw response 
106113
107114    def  analyze ( request ,  params  =  { } ) 
108-       http_client 
115+       response   =   http_client 
109116        . headers ( accept : "application/json" ) 
110117        . post ( "#{ base_url }  ,  json : request ,  params : params ) 
111-         . parse 
118+ 
119+       SearchFlip ::JSON . parse ( response . to_s ) 
112120    end 
113121
114122    # Fetches information about the specified index aliases. Raises 
@@ -124,10 +132,11 @@ def analyze(request, params = {})
124132    # @return [Hash] The raw response 
125133
126134    def  get_aliases ( index_name : "*" ,  alias_name : "*" ) 
127-       http_client 
135+       response   =   http_client 
128136        . headers ( accept : "application/json" ,  content_type : "application/json" ) 
129137        . get ( "#{ base_url } #{ index_name } #{ alias_name }  ) 
130-         . parse 
138+ 
139+       SearchFlip ::JSON . parse ( response . to_s ) 
131140    end 
132141
133142    # Returns whether or not the associated Elasticsearch alias already 
@@ -159,10 +168,11 @@ def alias_exists?(alias_name)
159168    # @return [Array] The raw response 
160169
161170    def  get_indices ( name  =  "*" ,  params : { } ) 
162-       http_client 
171+       response   =   http_client 
163172        . headers ( accept : "application/json" ,  content_type : "application/json" ) 
164173        . get ( "#{ base_url } #{ name }  ,  params : params ) 
165-         . parse 
174+ 
175+       SearchFlip ::JSON . parse ( response . to_s ) 
166176    end 
167177
168178    alias_method  :cat_indices ,  :get_indices 
@@ -259,10 +269,11 @@ def update_index_settings(index_name, index_settings)
259269    # @return [Hash] The index settings 
260270
261271    def  get_index_settings ( index_name ) 
262-       http_client 
272+       response   =   http_client 
263273        . headers ( accept : "application/json" ) 
264274        . get ( "#{ index_url ( index_name ) }  ) 
265-         . parse 
275+ 
276+       SearchFlip ::JSON . parse ( response . to_s ) 
266277    end 
267278
268279    # Sends a refresh request to Elasticsearch. Raises 
@@ -310,7 +321,9 @@ def get_mapping(index_name, type_name: nil)
310321      url  =  type_name  ? type_url ( index_name ,  type_name )  : index_url ( index_name ) 
311322      params  =  type_name  && version . to_f  >= 6.7  ? {  include_type_name : true  }  : { } 
312323
313-       http_client . headers ( accept : "application/json" ) . get ( "#{ url }  ,  params : params ) . parse 
324+       response  =  http_client . headers ( accept : "application/json" ) . get ( "#{ url }  ,  params : params ) 
325+ 
326+       SearchFlip ::JSON . parse ( response . to_s ) 
314327    end 
315328
316329    # Deletes the specified index from Elasticsearch. Raises 
0 commit comments