[[position-offset-gap]]
=== `position_offset_gap`

<<mapping-index,Analyzed>> string fields take term <<index-options,positions>>
into account, in order to be able to support
<<query-dsl-match-query-phrase,proximity or phrase queries>>.
When indexing an array of strings, each string of the array is indexed
directly after the previous one, almost as though all the strings in the array
had been concatenated into one big string.

This can result in matches from phrase queries spanning two array elements.
For instance:

[source,js]
--------------------------------------------------
PUT /my_index/groups/1
{
    "names": [ "John Abraham", "Lincoln Smith"]
}

GET /my_index/groups/_search
{
    "query": {
        "match_phrase": {
            "names": "Abraham Lincoln" <1>
        }
    }
}
--------------------------------------------------
// AUTOSENSE
<1> This phrase query matches our document, even though `Abraham` and `Lincoln` are in separate strings.

The `position_offset_gap` can introduce a fake gap between each array element.  For instance:

[source,js]
--------------------------------------------------
PUT my_index
{
  "mappings": {
    "my_type": {
      "properties": {
        "names": {
          "type": "string",
          "position_offset_gap": 50 <1>
        }
      }
    }
  }
}

PUT /my_index/groups/1
{
    "names": [ "John Abraham", "Lincoln Smith"]
}

GET /my_index/groups/_search
{
    "query": {
        "match_phrase": {
            "names": "Abraham Lincoln" <2>
        }
    }
}
--------------------------------------------------
// AUTOSENSE
<1> The first term in the next array element will be 50 terms apart from the
    last term in the previous array element.
<2> The phrase query no longer matches our document.

TIP: The `position_offset_gap` setting is allowed to have different settings
for fields of the same name in the same index.  Its value can be updated on
existing fields using the <<indices-put-mapping,PUT mapping API>>.

