@@ -98,14 +98,15 @@ def _build_composite(self, groupby):
9898 sources = []
9999 for elem in groupby :
100100 if elem == 'type' :
101- sources .append ({'type' : {'terms' : {'field' : 'type' }}})
101+ sources .append ({'type' : {'terms' : {'field' : 'type.keyword ' }}})
102102 elif elem == 'time' :
103103 # Not doing a date_histogram aggregation because we don't know
104104 # the period
105105 sources .append ({'begin' : {'terms' : {'field' : 'start' }}})
106106 sources .append ({'end' : {'terms' : {'field' : 'end' }}})
107107 else :
108- sources .append ({elem : {'terms' : {'field' : 'groupby.' + elem }}})
108+ field = 'groupby.' + elem + '.keyword'
109+ sources .append ({elem : {'terms' : {'field' : field }}})
109110
110111 return {"sources" : sources }
111112
@@ -158,12 +159,9 @@ def put_mapping(self, mapping):
158159 :rtype: requests.models.Response
159160 """
160161 url = '/' .join (
161- (self ._url , self ._index_name , '_mapping' , self ._mapping_name ))
162- # NOTE(peschk_l): This is done for compatibility with
163- # Elasticsearch 6 and 7.
164- param = {"include_type_name" : "true" }
162+ (self ._url , self ._index_name , self ._mapping_name ))
165163 return self ._req (
166- self ._sess .put , url , json .dumps (mapping ), param , deserialize = False )
164+ self ._sess .post , url , json .dumps (mapping ), {} , deserialize = False )
167165
168166 def get_index (self ):
169167 """Does a GET request against ES's index API.
@@ -228,7 +226,7 @@ def bulk_with_instruction(self, instruction, terms):
228226 """Does a POST request against ES's bulk API
229227
230228 The POST request will be done against
231- `/<index_name>/<mapping_name>/ _bulk`
229+ `/<index_name>/_bulk`
232230
233231 The instruction will be appended before each term. For example,
234232 bulk_with_instruction('instr', ['one', 'two']) will produce::
@@ -249,7 +247,7 @@ def bulk_with_instruction(self, instruction, terms):
249247 * [(instruction , json .dumps (term )) for term in terms ]
250248 )) + '\n '
251249 url = '/' .join (
252- (self ._url , self ._index_name , self . _mapping_name , '_bulk' ))
250+ (self ._url , self ._index_name , '_bulk' ))
253251 return self ._req (self ._sess .post , url , data , None , deserialize = False )
254252
255253 def bulk_index (self , terms ):
0 commit comments