G
G
GuF_20192020-09-02 12:26:20
MongoDB
GuF_2019, 2020-09-02 12:26:20

MongoDB doesn't give me all the documents I request. What's the problem?

There are 2 million documents in my database. Each document in my database has a separate id field which is numbered from 1 to the last document.
Also, each document has a data field which is an array of dictionaries. I need to find all documents, the first dictionary of the data field has a field with a value in my specified range (from 100 to 150 for example).
I send a request to the database {"data.0.value":{$gte:100, $lte:150}}, and the joke is that mongo does not give me all the documents.
I understood this by sorting the results and looking at the id of the very first document, and for some reason it starts with 200000 id. Although before that id there were documents with value lying in the range that we need. Please help me understand why this is happening.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hzzzzl, 2020-09-02
@hzzzzl

hmm strange, but if you try to paint the request in more detail like this?

$and: [
  {"data.0.value": { $gte:100 } },
  {"data.0.value" :{ $lte:150 } }
]

or if you just select { $gte:100 } and sort by id, will it also start with -_id 200000?

G
GuF_2019, 2020-09-02
@GuF_2019

I checked, it still fails.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question