Start a new topic

$or Operator is not working with $ne Values.

I'm trying to use several $ne values inside a $or Array in my business logic, to filter my collection.

For any reason i don't understand at the moment, something like this

 q_jobs = {

      _id : {$ne : modules.collectionAccess.objectID("XYZ")} ,


works fine.

But if i include it inside an $or operator (which i have to, cause i have to filter for more than 1 id this way) it stops working.

Fast Help would be great, cause this is really a stopper for me at the moment.


I am looking into this now.

Can you elaborate on what you mean by "stops working"? If you can give me detailed scenarios along with code snippets of queries, that should speed up the process.

Right now, I think you should be using and operator instead of or. But, I have not tested this hypothesis.



Kinvey Support

Hey Wani,

thanks for you answer.

"Can you elaborate on what you mean by "stops working"?"

Stops working, in this case, means that the results contains the entitidy, i want to exclude via the 

The scenario is a search request on our datacollection. Let's say i've loaded 20 results from the collection and the user wants to search for the next 20 entrys, i want to exclude the id's from the first Request, cause it make no sense to search through them again.

Best, Nici


If you are trying to search on the collection 20 (or 50) results at a time, you should try to use pagination. It's documented here:

Let me know if that helps.




i will try to clearify the problem:

We do have Entrys inside our Collection which can have several Tags. (array-field)
Our Users also have tags to match these entrys for each single user.  In Addition we give a percentage Value on how much the match is correct. (Like 2 of 4 Tags matches = 50%)

At the moment the logic is based on this answer

So let's say i have 100 entrys that are at least matching 1 tag with the user (otherwise it is ignored) So the Script have to run through all 100 Entrys and calculate the matching.
In our application we only show 20 results (or even less) at one time and using pagination/infinite scrolling in our lists. So my idea/goal is to exlude the already checked entrys from the next search-request to save some performance.
Therefore i send an array to the searchrequest containing all id's of the last results, to exclude them from the request.

So that's the situation - hope i can make my point? :P

I've tried to use the $or operator to do so, but as explained it doesn't work. So any hint would be great.

Best, NIco

Login or Signup to post a comment