Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

458
Views
Firestore: Inequality filter property and first sort order must be the same. Failing where condition and order in different fields. Is this Expected?

I have a collection of documents like this:

{
   uid: <UNIQUE_USER_ID>,
   lastLoggedIn: <TIMESTAMP_IN_NUMBER>,
   ...
}

when I try to fetch the data using:

Server.db
    .collection(firebasePaths.funfuse_verified_users)
    .where('uid', 'not-in', notToIncludeAccounts)
    .orderBy('lastLoggedIn', 'desc')
    .startAt(startAt)
    .limit(limit)

I get an error saying:

Error: 3 INVALID_ARGUMENT: inequality filter property and first sort order must be the same: uid 
and lastLoggedIn

Is this a known limitation of firebase or am I doing something wrong ? I want to query all the users which aren't in an array using not-in and then sort those results based on lastLoggedIn timestamp activity.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As the error message says, in order to be able to use not-in you must first order on the same field:

Server.db
    .collection(firebasePaths.funfuse_verified_users)
    .orderBy('uid')
    .where('uid', 'not-in', notToIncludeAccounts)
    .orderBy('lastLoggedIn', 'desc')
    .startAt(startAt)
    .limit(limit)

This also means that the results will be order first on uid and only then (so if there are multiple results with the same uid value) on lastLoggedIn. If you need them in another order, you will have to resort them in your application code.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!