简体   繁体   English

使用RestHeart查询MongoDB返回的结果与使用MongoDB客户端返回的结果不同

[英]Querying MongoDB with RestHeart returns different result than with MongoDB client

I have configured RestHeart to get data from MongoDB. 我已经配置RestHeart从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...). 与使用客户端查询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) 但是,像下面这样的一些请求涉及使用日期作为字符串的过滤器比使用MongoDB客户端花费更长的时间,并且Nginx在60s之后关闭连接(与客户端的同一查询花费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. 该集合具有DATE_A属性的索引,该索引在与客户端执行查询时使用。

The configuration of RestHeart is the same as the default configuration in the documentation with the difference of the connection to MongoDB. RestHeart的配置与文档中的默认配置相同,只是与MongoDB的连接不同。 In this case I use a cluster with 3 instances (1 Master and 2 slaves). 在这种情况下,我使用具有3个实例(1个主节点和2个从属节点)的群集。 Furthermore the RestHeart log file shows all the request that are executed except these requests so I can't see what happen with them. 此外,RestHeart日志文件显示了除这些请求之外所有已执行的请求,因此我看不到它们会发生什么。

Any suggestion in order to discover what and where is the issue with this queries? 有什么建议可以发现此查询的问题和原因在哪里? Thanks in advance. 提前致谢。

Restheart also sort result by _id descending by default. 默认情况下,Restheart还会以_id降序对结果进行排序。

Try adding sort={'date':-1} or build a compound index 尝试添加sort = {'date':-1}或构建复合索引

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM