Python3使用ES常见问题记录

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_32502511/article/details/86503654

1.使用Elasticsearch 6.x版本以上进行查询字段排序的时候,遇到报类似如下错误:

elasticsearch.exceptions.RequestError: RequestError(400, 'search_phase_execution_exception', 'Fielddata is disabled on text fields by default. Set fielddata=true on [article_time] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.')

解决办法:

删除掉已经创建好的index,然后重新创建,例如我这使用postman来创建,需要注意的是从新创建是时候,指定要排序的字段mappings下的fielddata属性为true。例如下图所示:

创建成功后切换到GET方式请求,如过出现如下图类似的内容则表示创建成功:

接下来,再到代码中加入排序字段运行查询,就不会报错了,如下图所示:

2.暂无

猜你喜欢

转载自blog.csdn.net/qq_32502511/article/details/86503654