【发布时间】:2018-01-19 03:05:30
【问题描述】:
使用聚合函数删除查询的重复项,使用 elastics search python lib 时出现以下错误:
elasticsearch.exceptions.RequestError: TransportError(400, 'search_phase_execution_exception', 'Fielddata 在文本上被禁用 默认情况下的字段。在 [uuid] 上设置 fielddata=true 以加载 fielddata 在内存中通过反转倒排索引。请注意,这 但是可以使用大量内存。或者使用关键字字段 ')
但正如建议的那样,我已经使用“uuid”的关键字字段重新创建了索引。这是我的映射:
In [46]: mapping = {
...: 'mappings': {
...: 'article': {
...: 'properties': {
...: 'publish_at': {
...: 'type': 'date'
...: },
...: 'uuid': {
...: 'type': 'text',
...: 'fields': {
...: 'keyword': {
...: 'type': 'keyword'
...: }
...: }
...: }
...: }
...: }
...: }
...: }
我做的查询是这样的:
es_body = {
'from' : self.limit_from,
'size' : 10,
'query': {
'bool': {
'must': {
'multi_match': {
'query': keywords,
'type':'best_fields',
'operator':'and',
'fields': [
'title','summary','keywords'
],
},
},
'filter': {
'term': {
'bot_id': self.current_bot.id
}
}
},
},
'aggs': {
'unique_uuids': {
'terms': {
'field': 'uuid'
}
}
}
}
对此有何建议?
【问题讨论】:
标签: elasticsearch