# Custom Term Vectors

**URL:** https://discuss.elastic.co/t/custom-term-vectors/315593
**Category:** Elasticsearch
**Created:** [September 30, 2022, 3:54pm UTC](https://discuss.elastic.co/t/custom-term-vectors/315593 "2022-09-30T15:54:22Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Tobias\_Fink](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tobias_fink/32/82564_2.png) [@Tobias\_Fink](https://discuss.elastic.co/u/Tobias_Fink)
#### Post date: [September 30, 2022, 3:54pm UTC](https://discuss.elastic.co/t/custom-term-vectors/315593/1 "2022-09-30T15:54:22Z")

</div>

Hello,

I'm trying to create custom term frequencies for terms in my documents, independent of the actual term frequencies in the document and including expansion terms that are not in the original document. Position and offset data are not needed. I was wondering what would be a good way to get this in Elasticsearch?

For example, if I have the document `"quick brown fox"`, instead of the frequencies

```auto
{"quick":1, "brown":1, "fox":1}

```

I want to have frequencies such as

```auto
{"quick":1, "brown":2, "fox":3, "mammal":2, "red":1}

```

One way I could think of would be just adding a second field that uses a Whitespace analyzer and contains a text with the exact frequencies that I want:

```auto
{
    "_source": {
        "text": "quick brown fox",
        "custom_tf": "quick brown brown fox fox fox mammal mammal red"
    }
}

```

But this seems a bit messy. Any ideas for a better solution?

---

<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: [October 28, 2022, 3:54pm UTC](https://discuss.elastic.co/t/custom-term-vectors/315593/2 "2022-10-28T15:54:24Z")

</div>

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