英文:
How to prevent ignored fields from being returned from Elastic Search
问题
我们有一个通过App Search
提供的Elastic Search
引擎,其具有非常庞大的架构(大量字段)。 这些字段中很多对于我们的搜索请求范围并不必要,并且在响应对象的_ignored
部分返回。 我们不仅不使用_ignored
数据,而且它们还在Elastic的响应对象中显著地膨胀,这并不理想。 有没有办法阻止从搜索请求的结果中返回_ignored
部分?
英文:
We have an Elastic Search
engine that has been provisioned through App Search
, and has a very large schema (large amount of fields). A lot of these fields are not necessary to the scope of our search requests and are returned in the _ignored
section of the response object. Not only do we not use the _ignored
data, but they are significantly bloating our response object from Elastic which is not ideal. Is there a way to prevent the _ignored
section form being returned as a part of the result from a search request?
答案1
得分: 1
"_ignored" 是 Elasticsearch 的元数据字段,因此无法使用源过滤选项进行过滤。
您需要使用 响应过滤,并在请求中使用 filter_path
参数。
以下是一个示例,它将在搜索响应中仅返回 took、_id、_score 和 _source。
POST index_name/_search?filter_path=took,hits.hits._id,hits.hits._score,hits.hits._source
{
"query": {
"exists": {
"field": "_ignored"
}
}
}
英文:
_ignored
is metadata field of elasticsearch hence it can not be filter using source filter option.
You need to use Response Filtering using filter_path
parameter in request.
Below is example where it will return only took, _id, _score, _source in search response.
POST index_name/_search?filter_path=took,hits.hits._id,hits.hits._score,hits.hits._source
{
"query": {
"exists": {
"field": "_ignored"
}
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论