I am trying to query Datastore and my query looks like this:
SELECT * FROM mydb WHERE Latitude = "18.1" AND Number > "1"
However, this does not work. I get this error in the Datastore request window:
GQL query error: your data warehouse does not have a composite index (supplied by the developer) for this query.
And this error when running my code:
no matching match index found. Recommended index: \ n- view: mydb \ n properties: \ n - name: Location \ n - name: Number \ n
Simple queries like this one work:
SELECT * FROM mydb WHERE Number > "1" AND Number < "5"
I can access only one column, maybe that's why?
Not,
Then I tried the query as follows:
SELECT * FROM mydb WHERE Latitude = "18.1" AND Number = "1"
It worked.
I tried to find a solution and I came across this page: https://cloud.google.com/datastore/docs/tools/indexconfig#Datastore_About_index_yaml
After going through this page, I realized that I needed the index.yaml file. It is assumed that it is located in the WEB-INF folder. But I do not have this folder.
This is a small piece of my code:
Query<Entity> query = Query .gqlQueryBuilder(Query.ResultType.ENTITY, "SELECT * FROM " + kind + " WHERE Location = @location AND Number <= @number") .setBinding("number", "5").setBinding("location", "18.1").build(); QueryResults<Entity> results = datastore.run(query);