如何防止Elastic Search返回被忽略的字段

huangapple go评论67阅读模式
英文:

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?

Edit
An example of the request and response
如何防止Elastic Search返回被忽略的字段

答案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"
    }
  }
}

huangapple
  • 本文由 发表于 2023年7月4日 23:12:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76613948.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定