0

I have configured RestHeart to get data from MongoDB. Most of the request work well and return the same results than if I use a client to query the MongoDB (RoboMongo, MongoDB Compass...). However some request like the following that involved filters with dates as strings take longer than with MongoDB clients and Nginx closes the connection after 60s (the same query with a client takes 0.163s)

## Request 
https://IP/DB/Collection/?filter={'DATE_A':'2017-08-24'}

## Query
db.getCollection('collection').find({'DATE_A':'2017-08-24'}) 

The collection has an index for DATE_A attribute that is used when the query is executed with a client.

The configuration of RestHeart is the same as the default configuration in the documentation with the difference of the connection to MongoDB. In this case I use a cluster with 3 instances (1 Master and 2 slaves). Furthermore the RestHeart log file shows all the request that are executed except these requests so I can't see what happen with them.

Any suggestion in order to discover what and where is the issue with this queries? Thanks in advance.

1 Answers1

1

Restheart also sort result by _id descending by default.

Try adding sort={'date':-1} or build a compound index

Andrea Di Cesare
  • 1,125
  • 6
  • 11
  • I have changed 'DATE_A' field type to Date type so now with a MongoDB client I get "DATE_A" : ISODate("2017-02-21T05:00:00.000Z"). I'm going to try to find now how to filter by dates using RestHeart. Thanks. – J. Morales Sep 28 '17 at 15:52