2017-03-08 58 views
0

嗨,我想通過python-elastic-search來映射。我想在我的代碼中添加大小寫映射。請檢查映射並幫助我。 500傳輸錯誤not_x_content_exception。ElasticSeach映射獲取錯誤

mapping = ''' 
{ 
    "settings": { 
     "index": { 
      "analysis": { 
       "analyzer": { 
        "analyzer_keyword": { 
         "tokenizer": "keyword", 
         "filter": "lowercase" 
        } 
       } 
      } 
     } 
    }, 
    "mappings": { 
     "countrycpm": { 
      "properties": { 
       "uid": { 
        "type": "text" 
       }, 
       "country": { 
        "type": "text" 
       }, 
       "cpm": { 
        "type": "float" 
       }, 
       "createdby": { 
        "type": "text" 
       }, 
       "updatedby": { 
        "type": "text" 
       }, 
       "createddate": { 
        "type": "date", 
        "format": "yyyy-MM-dd HH:mm:ss.SSS" 
       }, 
       "updateddate": { 
        "type": "date", 
        "format": "yyyy-MM-dd HH:mm:ss.SSS" 
       }, 
       "status = mode": { 
        "type": "integer" 
       }, 
       "createdbyname": { 
        "type": "text" 
       }, 
       "updatedbyname": { 
        "type": "text" 
       } 
      } 
     } 
    } 
} 
''' 

els.indices.put_mapping(index = ES_INDEX, doc_type = 'countrycpm',body=json.dumps(mapping)) 

響應

TransportError       Traceback (most recent call last) 
<ipython-input-57-4c3baa9096ca> in <module>() 
----> 1 els.indices.put_mapping(index = ES_INDEX, doc_type = 'countrycpm',body=json.dumps(map)) 

/usr/local/lib/python2.7/dist-packages/elasticsearch/client/utils.pyc in _wrapped(*args, **kwargs) 
    67     if p in kwargs: 
    68      params[p] = kwargs.pop(p) 
---> 69    return func(*args, params=params, **kwargs) 
    70   return _wrapped 
    71  return _wrapper 

/usr/local/lib/python2.7/dist-packages/elasticsearch/client/indices.pyc in put_mapping(self, doc_type, body, index, params) 
    289     raise ValueError("Empty value passed for a required argument.") 
    290   _, data = self.transport.perform_request('PUT', _make_path(index, 
--> 291    '_mapping', doc_type), params=params, body=body) 
    292   return data 
    293 

/usr/local/lib/python2.7/dist-packages/elasticsearch/transport.pyc in perform_request(self, method, url, params, body) 
    305 
    306    try: 
--> 307     status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout) 
    308 
    309    except TransportError as e: 

/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/http_urllib3.pyc in perform_request(self, method, url, params, body, timeout, ignore) 
    91   if not (200 <= response.status < 300) and response.status not in ignore: 
    92    self.log_request_fail(method, url, body, duration, response.status) 
---> 93    self._raise_error(response.status, raw_data) 
    94 
    95   self.log_request_success(method, full_url, url, body, response.status, 

/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/base.pyc in _raise_error(self, status_code, raw_data) 
    103    pass 
    104 
--> 105   raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info) 
    106 
    107 

TransportError: TransportError(500, u'not_x_content_exception') 

回答

0

不能更新這樣在指數映射,你創建新的映射,並指定該映射作爲新的變量否則你已經刪除索引並相應地進行更新。