Skip to content
Advertisement

Objectify with Firestore native – no matching index found

I have a collection of very simple Java objects which I store in Google Firestore database (native mode) using Objectify 6.0.7. Storing, deleting, and querying objects all work fine, but a query with an orderBy clause on a single field fails with “no matching index found”. The exact same code works perfectly in a Datastore project (so the Java code is not in question).

I could not find clear documentation as to whether Objectify can work with Firestore and I suspect this is the issue. Thoughts?

This is the query:

JavaScript

and this is a sample record from that collection (French locale, but the date objects are valid):

JavaScript

Using an ascending order, e.g. order("desc") also fails, but removing the .order('-desc') function from the query altogether does not cause any error but of course returns results in random order.

I understand from the documentation that all single-field indexes should be created by default in Firestore and I see no way to create a single field index in the console. I therefore assume that an index exists for the date field used in the order function.

Advertisement

Answer

Objectify v6 uses the com.google.cloud:google-cloud-datastore library as a low-level API. I’m pretty sure that library only works in Datastore Mode. Google has a completely different (and much more primitive) Java library for Firestore Mode.

So I think for now you need to use Datastore Mode and not Firestore Mode.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement