Elasticsearch:使用关键字映射插入的字段变为字符串类型

时间:2018-08-29 23:03:15

标签: python python-3.x elasticsearch

Elasticsearch版本:5.6.5

我正在使用Elasticsearch Python API创建索引和批量插入文档:

 import numpy as np
 dimension = 4    # other matrices' dimensions will be larger
 matrix = np.zeros((dimension,dimension))

 register = [11, 12, 13, 23, 24, 34]

 progress = 0
 inner_step = 0
 i = 0

 for progress in range(0, (dimension + 1)):
 permitted_steps = dimension - progress
 for i in range(progress, permitted_steps-1):
     matrix[(progress, inner_step+1+offset)] = register[0]
     matrix[(inner_step+1+offset, progress)] = register[0]
     inner_step += 1
     del register[0]

 progress += 1
 inner_step = 0
 offset += 1

但是,上面的代码创建了一个EVENT = { "mappings": { "my_mapping": { "properties": { "event_time": { "type": "date" }, "some_field": { "type": "keyword" } } } } } es = Elasticsearch("localhost") es.indices.create(index="some_index", ignore=400, body=EVENT) actions = [ { '_index': index, '_type': "my_mapping", '_source': doc } for doc in a_list_of_dictionaries] helpers.bulk(es, actions, raise_on_error=True, request_timeout=15) 类型而不是string的“ some_field”字段,我还看到了一个自动填充的名为“ some_field.keyword”的字符串字段。

如何创建keyword字段,以便仅搜索完全匹配的单词?

0 个答案:

没有答案