Multiple Select In Google Datastore Query Throwing Apierror: Precondition Failed Error In Node
I'm using following query to retrieve some entities from google Datastore: The above code works fine if I select only one property i.e. But with multiple select its throwing 412
Solution 1:
You need to create a multi-property index in order to use multi-property queries.
Because you are not using App Engine, these indexes need to be manually created.
I have a tutorial here that covers this.
Here are the steps:
- Install Java 7 Runtime (or later version) http://java.com/
- I recommend using Cloud Shell which has Java already installed and configured
- Create a folder called WEB-INF
- Inside that folder, you need three files:
- appengine-web.xml (replace YOUR_PROJECT_ID_HERE with your project ID)
- web.xml
- datastore-indexes.xml (Remove the indexes I used for my sample)
- In the datastore-indexes.xml file, you need to define your multi-property indexes. Follow the documentation.
- Install the gcd tool
- Finally, run the gcd tool (one directory above the WEB-INF folder)
- Linux/Mac
path/to/gcd.sh updateindexes --auth_mode=oauth2 .
- Windows
path/to/gcd.cmd updateindexes --auth_mode=oauth2 .
- Linux/Mac
After a few minutes, your indexes should be created.
Post a Comment for "Multiple Select In Google Datastore Query Throwing Apierror: Precondition Failed Error In Node"