Spec-Zone.ru › Elasticsearch 8
›Elasticsearch Guide [8.17] ›Query DSL ›Span queries

Span near query

Matches spans which are near one another. One can specify slop, the maximum number of intervening unmatched positions, as well as whether matches are required to be in-order. Here is an example:

resp = client.search(
    query={
        "span_near": {
            "clauses": [
                {
                    "span_term": {
                        "field": "value1"
                    }
                },
                {
                    "span_term": {
                        "field": "value2"
                    }
                },
                {
                    "span_term": {
                        "field": "value3"
                    }
                }
            ],
            "slop": 12,
            "in_order": False
        }
    },
)
print(resp)
response = client.search(
  body: {
    query: {
      span_near: {
        clauses: [
          {
            span_term: {
              field: 'value1'
            }
          },
          {
            span_term: {
              field: 'value2'
            }
          },
          {
            span_term: {
              field: 'value3'
            }
          }
        ],
        slop: 12,
        in_order: false
      }
    }
  }
)
puts response
const response = await client.search({
  query: {
    span_near: {
      clauses: [
        {
          span_term: {
            field: "value1",
          },
        },
        {
          span_term: {
            field: "value2",
          },
        },
        {
          span_term: {
            field: "value3",
          },
        },
      ],
      slop: 12,
      in_order: false,
    },
  },
});
console.log(response);
GET /_search
{
  "query": {
    "span_near": {
      "clauses": [
        { "span_term": { "field": "value1" } },
        { "span_term": { "field": "value2" } },
        { "span_term": { "field": "value3" } }
      ],
      "slop": 12,
      "in_order": false
    }
  }
}

The clauses element is a list of one or more other span type queries and the slop controls the maximum number of intervening unmatched positions permitted.

© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/query-dsl-span-near-query.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API