# Term vectors for nested fields

**URL:** https://discuss.elastic.co/t/term-vectors-for-nested-fields/318348
**Category:** Elasticsearch
**Created:** [November 7, 2022, 3:57pm UTC](https://discuss.elastic.co/t/term-vectors-for-nested-fields/318348 "2022-11-07T15:57:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![gioele](https://avatars.discourse-cdn.com/v4/letter/g/8491ac/32.png) [@gioele](https://discuss.elastic.co/u/gioele)
#### Post date: [November 7, 2022, 3:57pm UTC](https://discuss.elastic.co/t/term-vectors-for-nested-fields/318348/1 "2022-11-07T15:57:37Z")

</div>

Hi everyone.  
I'm trying to use the [mtermvectors api](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html) to get the term vectors (with term\_statistics) for an artificial document having several nested fields. I noticed however that, while for standard fields this works without issues, I can't figure out a way to get the term vectors for the nested fields in the artificial document.  
To reproduce:

```auto
PUT /my-index-000001
{
  "mappings": {
    "properties": {
      "user": {
        "type": "nested",
        "properties": {
            "first" : {
                "type": "text"
            },
            "last" : {
                "type": "text"
            },
            "description":{
                "type": "text"
            }
        }
      }
    }
  }
}
PUT /my-index-000001/_doc/1
{
  "group" : "fans",
  "user" : [
    {
      "first" : "John",
      "last" : "Smith",
      "description":"first description"
    },
    {
      "first" : "Alice",
      "last" : "White",      
      "description":"second description"
    }
  ]
}

```

finally, to get the term vector for the artificial document

```auto
GET my-index-000001/_mtermvectors
{ 
   "docs": [ 
    { 
        "doc" : {
            "group":"test",
            "user" : [
                {
                "first" : "John",
                "last" : "Smith",
                "description":"artificial description"
                }
            ]
        }, 
        "fields": ["*"], 
        "term_statistics":true,
        "positions":false,
        "offsets":false
    }
   ]
}

```

produces the response

```auto
{
    "docs": [
        {
            "_index": "my-index-000001",
            "_type": "_doc",
            "_version": 0,
            "found": true,
            "took": 0,
            "term_vectors": {
                "group": {
                    "field_statistics": {
                        "sum_doc_freq": 1,
                        "doc_count": 1,
                        "sum_ttf": 1
                    },
                    "terms": {
                        "test": {
                            "term_freq": 1
                        }
                    }
                }
            }
        }
    ]
}

```

which is missing the term vectors for the nested fields.

Is this a bug or am I missing something in the query/mapping?

---

<div class="post-metadata">

### Author: ![gioele](https://avatars.discourse-cdn.com/v4/letter/g/8491ac/32.png) [@gioele](https://discuss.elastic.co/u/gioele)
#### Post date: [November 14, 2022, 2:31pm UTC](https://discuss.elastic.co/t/term-vectors-for-nested-fields/318348/2 "2022-11-14T14:31:48Z")

</div>

Has anyone ever dealt with this issue?

---

<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 12, 2022, 2:32pm UTC](https://discuss.elastic.co/t/term-vectors-for-nested-fields/318348/3 "2022-12-12T14:32:17Z")

</div>

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