# Pre-filtering for \_termvectors API to get statistics on a subset of documents

**URL:** <https://discuss.elastic.co/t/pre-filtering-for-termvectors-api-to-get-statistics-on-a-subset-of-documents/265540>\
**Category:** Elasticsearch\
**Created:** [February 25, 2021, 8:42pm UTC](https://discuss.elastic.co/t/pre-filtering-for-termvectors-api-to-get-statistics-on-a-subset-of-documents/265540 "2021-02-25T20:42:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbaronas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bbaronas/32/116240_2.png) [@bbaronas](https://discuss.elastic.co/u/bbaronas)\
**Post date:** [February 25, 2021, 8:42pm UTC](https://discuss.elastic.co/t/pre-filtering-for-termvectors-api-to-get-statistics-on-a-subset-of-documents/265540/1 "2021-02-25T20:42:33Z")

</div>

Is there a way to pre-filter documents for the \_termvector API to get statistics limited to a subset of the documents in an index?

I would like to use the term vector API to look at tf/idf, etc. for items in my index, but I would like to be able to limit the scope by a field value ('userId'). The results I get from my \_termvector query appears to include all items in my index.

---

<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:** [March 25, 2021, 8:42pm UTC](https://discuss.elastic.co/t/pre-filtering-for-termvectors-api-to-get-statistics-on-a-subset-of-documents/265540/2 "2021-03-25T20:42:41Z")

</div>

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