The Nested query type in Elasticsearch is used to search documents containing nested fields. This query type allows you to search for documents that match specific criteria within nested fields.

To perform a Nested query, use the following query format:

GET /index/_search
{
  "query": {
    "nested": {
      "path": "campo_anidado",
      "query": {
        // Specific query for the nested field
      }
    }
  }
}

Where:

  • /index/_search is the API path to perform a search query on the specified index.
  • "query" is the parameter indicating a query will be performed.
  • "nested" is the type of query to be executed.
  • "path" is the name of the nested field where the query will be performed.
  • "query" is the specific query for the nested field.

Within the specific query for the nested field, you can use different query types, such as match, term, range, among others, to search for documents that match your specific criteria.

It's important to note that when using Nested queries, you need to properly configure the index mapping to indicate which fields are nested. Additionally, Nested queries can be slower than regular queries, as they involve searching within more complex data structures.


原文地址: https://www.cveoy.top/t/topic/o3VN 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录