# Term Vector With BiGrams

**URL:** https://discuss.elastic.co/t/term-vector-with-bigrams/86887
**Category:** Elasticsearch
**Created:** [May 24, 2017, 2:26am UTC](https://discuss.elastic.co/t/term-vector-with-bigrams/86887 "2017-05-24T02:26:55Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![vishva\_deepak\_tewari](https://avatars.discourse-cdn.com/v4/letter/v/f07891/32.png) [@vishva\_deepak\_tewari](https://discuss.elastic.co/u/vishva_deepak_tewari)
#### Post date: [May 24, 2017, 2:26am UTC](https://discuss.elastic.co/t/term-vector-with-bigrams/86887/1 "2017-05-24T02:26:55Z")

</div>

Hi,  
I have a a document which contains a subdocument, as such I have made the subdocument a nested property of the document. Now i need to find term vectors for the sub document. My terms can be unigrams or bigrams, hence I created an analyzer with shingle filter. The setting for the index is as follows

```
{
  "settings": {
    "analysis": {
      "filter": {
        "light_english_stemmer": {
		  "type": "stemmer",
          "language": "light_english" 
        },
        "filter_shingle":{
		   "type":"shingle",
		   "max_shingle_size":3,
		   "min_shingle_size":2,
		   "output_unigrams":"true",
		   "filler_token" : ""
		}
      },
      "analyzer": {
        "keyword_discovery_analyzer": {
          "tokenizer": "standard",
          "char_filter": ["html_strip"],
          "filter": [
            "lowercase",
            "filter_shingle",
            "light_english_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
  	"doc" : {
  		"properties" : {
  			"name" : {
  				"type" : "text"
  			},
  			"description" : {
  				"type" : "text",
  				"analyzer" : "indexing_analyzer",
  				"search_analyzer": "search_analyzer",
  				"fields" : {
  					"termVec": { 
		              "type" : "text",
		              "term_vector": "yes",
			          "store" : true,
			          "analyzer" : "keyword_discovery_analyzer"
		            }
  				}
  			},
  			"subDoc" : {
  				"type" : "nested",
  				"properties" : {
  					"name" : {
		  				"type" : "text",
		  				"fields" : {
							"termVec": { 
				              "type" : "text",
				              "term_vector": "yes",
					          "store" : true,
					          "analyzer" : "keyword_discovery_analyzer"
				            }
  						}
		  			},
		  			"description" : {
		  				"type" : "text",
		  				"fields" : {
							"termVec": { 
				              "type" : "text",
				              "term_vector": "yes",
					          "store" : true,
					          "analyzer" : "keyword_discovery_analyzer"
				            }
  						}
		  			}
  				}
  			}
  		}
  	}
  }
}

```

When i execute request  
GET /\_termvectors  
{  
"fields" : ["subDoc.name.termVec"],  
"offsets" : false,  
"payloads" : false,  
"positions" : false,  
"term\_statistics" : true,  
"field\_statistics" : true,  
"filter" :{  
"max\_num\_terms" : 4  
}  
}

I get empty result. However if instead of the above query i run the following,  
GET /12631946/\_termvectors  
{  
"fields" : ["[subDoc.name](http://subDoc.name)"],  
"offsets" : false,  
"payloads" : false,  
"positions" : false,  
"term\_statistics" : true,  
"field\_statistics" : true,  
"per\_field\_analyzer" : {  
"name": "keyword\_discovery\_analyzer"  
},  
"filter" :{  
"max\_num\_terms" : 15  
}  
}

ES would evaluate term vectors on the fly, and i get the results, but none of the results contains bigram terms all are unigrams.

My analyzer is working correctly, because when I put the same analyzer on my [doc.name](http://doc.name) variable it gives me bigrams when term vectors are computed and stored, however in [doc.name](http://doc.name) as well, if the term vectors are computed at runtime, it always returns me unigrams.

Please let me know what i am doing wrong.

Thanks  
Vishvadeepak Tewari

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [May 26, 2017, 9:07am UTC](https://discuss.elastic.co/t/term-vector-with-bigrams/86887/2 "2017-05-26T09:07:18Z")

</div>

Hmm this looks like a bug to me. Want to open an issue?

---

<div class="post-metadata">

### Author: ![vishva\_deepak\_tewari](https://avatars.discourse-cdn.com/v4/letter/v/f07891/32.png) [@vishva\_deepak\_tewari](https://discuss.elastic.co/u/vishva_deepak_tewari)
#### Post date: [May 30, 2017, 6:22am UTC](https://discuss.elastic.co/t/term-vector-with-bigrams/86887/3 "2017-05-30T06:22:58Z")

</div>

Yep, what do i need to open issue for this ?

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [May 30, 2017, 7:03am UTC](https://discuss.elastic.co/t/term-vector-with-bigrams/86887/4 "2017-05-30T07:03:16Z")

</div>

Just go to [https://github.com/elastic/elasticsearch/issues/new](https://github.com/elastic/elasticsearch/issues/new) and provide the info requested.

---

<div class="post-metadata">

### Author: ![vishva\_deepak\_tewari](https://avatars.discourse-cdn.com/v4/letter/v/f07891/32.png) [@vishva\_deepak\_tewari](https://discuss.elastic.co/u/vishva_deepak_tewari)
#### Post date: [June 6, 2017, 10:28am UTC](https://discuss.elastic.co/t/term-vector-with-bigrams/86887/5 "2017-06-06T10:28:37Z")

</div>

created an issue [https://github.com/elastic/elasticsearch/issues/25070](https://github.com/elastic/elasticsearch/issues/25070)

---

<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: [July 4, 2017, 10:28am UTC](https://discuss.elastic.co/t/term-vector-with-bigrams/86887/6 "2017-07-04T10:28:43Z")

</div>

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