# \_mtermvectors very slow?

**URL:** https://discuss.elastic.co/t/-mtermvectors-very-slow/59069
**Category:** Elasticsearch
**Created:** [August 26, 2016, 6:54pm UTC](https://discuss.elastic.co/t/-mtermvectors-very-slow/59069 "2016-08-26T18:54:03Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![MaJaHa95](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/majaha95/32/26121_2.png) [@MaJaHa95](https://discuss.elastic.co/u/MaJaHa95)
#### Post date: [August 26, 2016, 6:54pm UTC](https://discuss.elastic.co/t/-mtermvectors-very-slow/59069/1 "2016-08-26T18:54:03Z")

</div>

Hello,

I've got an ML pipeline that involves running a query against Elasticsearch, pulling down the resultant IDs, then passing those (in chunks) to \_mtermvectors to retrieve _full_ tokenized results. Notably, I'm not looking for the "most interesting" terms, or anything like that: I just want to benefit from Elasticsearch's awesome tokenization platform, since we've already got our data there anyway.

I have this all in place, but I find it extremely slow. Pulling back 1,000 documents' term vectors can take minutes (although around one minute is pretty typical). I understand quite a bit of data needs to be passed around here, and I probably won't get it down to milliseconds, but this surprised me. I could pull back the 1,000 raw `source` data fields in a few seconds.

I'm running this in a VNet on Azure. I don't know the exact specs, but it's not like it's running over 3G--I don't think network transfer is the biggest expense here.

I set up my mapping with [`term_vector` enabled](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/term-vector.html).

```auto
...
"text": {
    "term_vector": "yes",
    "type": "string",
    "fields": { ... }
}
...

```

And query against it like this:

```auto
POST /esproxy/cases/_mtermvectors
        ?term_statistics=false
        &positions=false
        &field_statistics=false
        &offsets=false
        &payloads=false
        &realtime=false
        &filter_path=docs._id%2Cdocs.term_vectors
        &fields=text

{
    "docs": [{
        "_index": "cases",
        "_type": "casedocument",
        "_id": "1346619000",
        "filter": {
            "max_num_terms": 1000
        }
    }, {
        "_index": "cases",
        "_type": "casedocument",
        "_id": "1346620986",
        "filter": {
            "max_num_terms": 1000
        }
    },
    ...]
}

```

I've tried it with several batch sizes, including 1, 100, and 1000, and the time scales more or less linearly. I save a few seconds by doing larger batches, as expected, but nothing game-changing in either direction.

So, my questions:

1. Is this sort of performance just normal? It's possible that I'm reading into it way too much, and this is just how long it takes to move data around.
2. Is there a better way to get the raw tokenized data out of Elasticsearch? If nothing else, that `"max_num_terms": 1000` seems insanely sketchy to me, but I haven't found a way to mark it as unlimited.
3. Depending on the answers here, I might look into putting the ML into a plugin directly against Elasticsearch (which would be independently cool, but would limit our other capabilities a bit). Could that help?

For what it's worth, I'm potentially running this against 100,000 documents (ideally more, but I've got sign-off to limit to that), so any savings would help.

I've got a cluster with three nodes, each at 28GB of RAM. I would understand if that was my limiting factor, and I can accept that as an answer if it is. I can't "just try more," and I'd love better solutions, but I'd at least understand.

My quick-and-dirty solution has been to run the calls in parallel, which is fine with me, but I'd love to make each thread return a little more quickly.

Thanks,  
Matthew

---

<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, 10:13pm UTC](https://discuss.elastic.co/t/-mtermvectors-very-slow/59069/2 "2017-07-05T22:13:32Z")

</div>


