2017-03-08 1 views
0

안녕하세요 저는 python - elastic - search.I 통해 putmapping 노력하고있어 내 코드에서 사례 집중 매핑을 추가하고 싶습니다. 매핑을 확인하고 도와주세요. not_x_content_exception 전송 오류가 500 번 발생했습니다. 색인이 같은 매핑을 업데이트 할 수 없습니다ElasticSeach 매핑 오류가 발생했습니다

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

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)) 

응답, 당신은 다른 당신은을 삭제했습니다 그 새로운 변수로이 매핑을 새로운 매핑을 생성하고 할당했습니다 색인을 생성하고 그에 따라 업데이트하십시오.

관련 문제