# Way to store extracted list of terms in elasticsearch (array, text, ...)

**URL:** https://discuss.elastic.co/t/way-to-store-extracted-list-of-terms-in-elasticsearch-array-text/36312
**Category:** Elasticsearch
**Created:** [December 3, 2015, 5:49pm UTC](https://discuss.elastic.co/t/way-to-store-extracted-list-of-terms-in-elasticsearch-array-text/36312 "2015-12-03T17:49:33Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![aalex](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@aalex](https://discuss.elastic.co/u/aalex)
#### Post date: [December 3, 2015, 5:49pm UTC](https://discuss.elastic.co/t/way-to-store-extracted-list-of-terms-in-elasticsearch-array-text/36312/1 "2015-12-03T17:49:33Z")

</div>

Hello!

I have a list of already extracted terms and I don't want to analyze them again (so I mark field "not\_analyzed").  
Next I'm trying to store them as array of strings. Here is an example:

```
// create index 

curl -XPUT 'http://localhost:9200/test/' -d '{                               
     "settings" : {
        "number_of_shards" : 1,
        "number_of_replicas" : 0
     },  
     "mappings": {
        "doc": {
            "properties": {
                "terms": {
                    "type": "string",
                    "index" : "not_analyzed", 
                    "term_vector" : "yes"   
                }
            }
        }
    }
}'

// some data

curl -XPUT 'http://localhost:9200/test/doc/1' -d '{
    "terms" : ["quick", "brown", "fox"]
}'

curl -XPUT 'http://localhost:9200/test/doc/2' -d '{
    "terms" : ["the", "red", "fox", "fox"]
}'

```

**1) Term\_vectors**  
All terms have correct term\_freq and doc\_freq values, but ttf == -1.

```
curl -XGET 'http://localhost:9200/test/doc/1/_termvectors?pretty=true' -d'{
    "term_statistics" : true,
    "field_statistics" : true
}'

```

**2) Finding similar documents for document with \_id = 1.**  
Explain query show that term "fox" has tf == 1.0, but I expected 2.0.

```
curl -XPOST 'http://localhost:9200/test/doc/_search?explain' -d '{
    "query": {
        "more_like_this": {
            "fields": ["terms"],
            "like": [{"_id" : "1"}],
            "min_term_freq": 1,
            "min_doc_freq": 1
        }
    }
}'

```

I know what I can concatenate terms into string and store it, use elastic's analyzer (ex  
Whitespace Analyzer) to build terms.

But I wonder whether it is possible to store terms in array of string and have correct "tf" in explain query and "ttf" value for each terms in vector?

\*If I mark field "terms" as "analyzed" all working fine =\> ttf and tf calculated correctly.

---

<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 5, 2017, 11:33pm UTC](https://discuss.elastic.co/t/way-to-store-extracted-list-of-terms-in-elasticsearch-array-text/36312/2 "2017-07-05T23:33:47Z")

</div>


