# ES, MongoDB and performance

**URL:** <https://discuss.elastic.co/t/es-mongodb-and-performance/174935>\
**Category:** Elasticsearch\
**Created:** [April 2, 2019, 8:02am UTC](https://discuss.elastic.co/t/es-mongodb-and-performance/174935 "2019-04-02T08:02:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mushishi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mushishi/32/43254_2.png) [@mushishi](https://discuss.elastic.co/u/mushishi)\
**Post date:** [April 2, 2019, 8:02am UTC](https://discuss.elastic.co/t/es-mongodb-and-performance/174935/1 "2019-04-02T08:02:20Z")

</div>

Hi,

I have near 1 billion documents in MongoDB instance and they're nearly similar so I'm storing them in a single collection. I'm using mongo-connector to import this collection to ES. Each document has a name field (string) and value field (int, float, bool, array).

I need to do a text search and a range query. I'm using 'match' on name field for text search and 'must' for range query on value (int, float) among documents having a particular name field using 'match' on name and 'range' on value.

Is there a better way to do this performance wise?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 2, 2019, 8:17am UTC](https://discuss.elastic.co/t/es-mongodb-and-performance/174935/2 "2019-04-02T08:17:14Z")

</div>

I'd use filter instead of must for all the exact values or ranges...

---

<div class="post-metadata">

**Author:** ![mushishi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mushishi/32/43254_2.png) [@mushishi](https://discuss.elastic.co/u/mushishi)\
**Post date:** [April 3, 2019, 4:13am UTC](https://discuss.elastic.co/t/es-mongodb-and-performance/174935/3 "2019-04-03T04:13:40Z")

</div>

Can I change document structure to improve search performance? For eg, instead of documents with structure as {name: abc, value: xyz}, grouping documents with same name like {same\_name: abc, collection: [{name: def, value: 1}, {name: edf, value: 2}] }. Is there any increase?

Basically, I'm trying to increase search speed for semi-structured data. Also match supports querying partial words right?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 3, 2019, 5:41am UTC](https://discuss.elastic.co/t/es-mongodb-and-performance/174935/4 "2019-04-03T05:41:45Z")

</div>

It would be easier to understand if you provide a document, the mapping, a typical query and the `took` value of a search response.

---

<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:** [May 1, 2019, 5:41am UTC](https://discuss.elastic.co/t/es-mongodb-and-performance/174935/5 "2019-05-01T05:41:45Z")

</div>

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