How to query on indexed array field to get two matching results


I am recording in a single record two events (bitcion input and its expenditure). Each event has a different time. I used to record both times in different fields (utxo_time, spent_time). But indexes didn’t work in two fields cause they first classify in one fiedl and then on the other when I want them to be treated at same level.
Then I created an array field time: [time1, time2] or [time1]. But when I make a search based on this time field I get oknly a result so if I order by time only the earliest time of the two is used.

How can I get two results from [time1, time2], and of course only one from [time1]?


Hi @Eduardo_Cobian,

To help understand what you are trying to achieve, please provide some more information:

  • specific version of MongoDB server
  • some example documents
  • search query you are using
  • desired output