# Help: Why is ElasticSearch querying a second MongoDB database instead?

**URL:** <https://discuss.elastic.co/t/help-why-is-elasticsearch-querying-a-second-mongodb-database-instead/7408>\
**Category:** Elasticsearch\
**Created:** [April 19, 2012, 11:42pm UTC](https://discuss.elastic.co/t/help-why-is-elasticsearch-querying-a-second-mongodb-database-instead/7408 "2012-04-19T23:42:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriel\_Mansour](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_mansour/32/2909_2.png) [@Gabriel\_Mansour](https://discuss.elastic.co/u/Gabriel_Mansour)\
**Post date:** [April 19, 2012, 11:42pm UTC](https://discuss.elastic.co/t/help-why-is-elasticsearch-querying-a-second-mongodb-database-instead/7408/1 "2012-04-19T23:42:06Z")

</div>

Hi there,

I'm trying to use ElasticSearch for my MongoDB-backed Rails 3.2.2 app  
(through Tire [https://github.com/karmi/tire](https://github.com/karmi/tire)).

I'm having a very strange issue where ElasticSearch seems to be  
returning query results from a second MongoDB database instead of the  
one for this app (as defined in my config/mongoid.yml file). This is  
very bizarre!

When I do Event.all, I see all the right events.

However, when I try to do Event.tire.search("foo") (or  
Event.tire.search('\*') even), it gives me the results from another  
app's MondoDB database instead!

I would expect Tire to tell ElasticSearch to use this app's database  
automatically, but failing that, would there be a way to set it  
explicitly?

Any help with this issue would be greatly appreciated. Thanks!

Cheers,  
Gabriel

---

<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 6, 2017, 3:31am UTC](https://discuss.elastic.co/t/help-why-is-elasticsearch-querying-a-second-mongodb-database-instead/7408/2 "2017-07-06T03:31:48Z")

</div>

Closed on July 6, 2017, 3:31am UTC


