# Nested objects proximity query

**URL:** <https://discuss.elastic.co/t/nested-objects-proximity-query/206410>\
**Category:** Elasticsearch\
**Created:** [November 4, 2019, 1:15pm UTC](https://discuss.elastic.co/t/nested-objects-proximity-query/206410 "2019-11-04T13:15:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trausti\_Dagsson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trausti_dagsson/32/57094_2.png) [@Trausti\_Dagsson](https://discuss.elastic.co/u/Trausti_Dagsson)\
**Post date:** [November 4, 2019, 1:15pm UTC](https://discuss.elastic.co/t/nested-objects-proximity-query/206410/1 "2019-11-04T13:15:00Z")

</div>

Hello everyone.  
Is it possible to query on nested data and take into account nested items proximity?

Let me hopefully make myself understandable:  
Look at the example below, it is a part of a sentence where each word is a nested object and each word has been tagged by a POS tagger for the Icelandic language and therefore each word includes some metadata that I want to query.  
What I want is to find e.g. two words (two nested objects) with specific attributes with X distance between. For example "expanded\_tag.ordflokkur": "nafnorð" (noun) and "expanded\_tag\_ordflokkur" = "sagnorð" (verb) that come in order right next to each other.

```auto
{
  "words": [
    {
      "expanded_tag": {
        "fall": "nefnifall",
        "greinir": "með viðskeyttum greini",
        "kyn": "karlkyn",
        "orðflokkur": "nafnorð",
        "tala": "eintala"
      },
      "lemma": "landi",
      "tag": "nkeng",
      "word": "Landinn"
    },
    {
      "expanded_tag": {
        "háttur": "framsöguháttur",
        "mynd": "germynd",
        "orðflokkur": "sagnorð",
        "persóna": "3. persóna",
        "tala": "eintala",
        "tíð": "þátíð"
      },
      "lemma": "fá",
      "tag": "sfg3eþ",
      "word": "fékk"
    },
    {
      "expanded_tag": {
        "fall": "þolfall",
        "kyn": "hvorugkyn",
        "orðflokkur": "nafnorð",
        "tala": "eintala"
      },
      "lemma": "far",
      "tag": "nheo",
      "word": "far"
    },
    {
      "expanded_tag": {
        "fallstjórn": "stýrir þágufalli",
        "orðflokkur": "atviksorð"
      },
      "lemma": "með",
      "tag": "aþ",
      "word": "með"
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 2, 2019, 1:20pm UTC](https://discuss.elastic.co/t/nested-objects-proximity-query/206410/2 "2019-12-02T13:20:00Z")

</div>

Closed on December 2, 2019, 1:20pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
