Google App Engine error: NeedIndexError: no matching index found

前端 未结 6 1600
说谎
说谎 2020-12-15 18:33

I\'m having trouble with Google\'s App engine indexes. When running my app via the GoogleAppEngineLauncher, the app is working fine. When deploying the app, I get the follow

相关标签:
6条回答
  • 2020-12-15 19:20

    I stumbled on the same issue and your comments helped me in the right direction. Here's what Google says how to handle this:

    According to the Google documentation the story is that using

    gcloud app deploy 
    

    the index.yaml file is not uploaded (question is why not?). Anyway, one has to upload this index file manually.

    To do so, the documentation gives the following command:

    gcloud datastore create-indexes index.yaml
    

    (supposing you execute this from the same directory of the index.yaml file) Once you have done this you can go to the Datastore console and you will see the index has been created. It will then start to be indexed (took some 5 minutes in my case) and once the index is being served you can start your application.

    0 讨论(0)
  • 2020-12-15 19:25

    I fixed this issue by moving the index that the error says is missing above the auto generate line in the "index.yaml" file.

    In your case the yaml file will look like:

    indexes:
    - kind: Bar
     ancestor: yes
     properties:
     - name: rating
       direction: desc
    
    # AUTOGENERATED
    

    Then all you have to do is update your app then update the indexes, you update the indexes by running the following command.

    appcfg.py [options] update_indexes <directory>
    

    With the directory being the directory relative to your index.yaml file. You should then see that index on your dashboard at https://appengine.google.com/datastore/indexes

    The update will initially be "pending" but after the index says "serving" you will be able to make your query.

    0 讨论(0)
  • 2020-12-15 19:34

    Check https://appengine.google.com/datastore/indexes to see if this index is present and status set to "serving". It's possible that the index is still being built.

    The development environment emulates the production environment. It does not really have indexes in the Datastore sense.

    0 讨论(0)
  • 2020-12-15 19:35

    Probably a little late now, but running "gcloud app deploy index.yaml" helped since running deploy by itself ignored the index.yaml file.

    As others have said, the dashboard at https://appengine.google.com/datastore/indexes will be showing "pending" for a while.

    0 讨论(0)
  • 2020-12-15 19:35

    This NeedIndexError can be triggered by different causes, as I arrived here while having a slightly different problem, so I'll try to explain all I was doing wrong in order to show things that can be done:

    • I thought I have to had only one index per Kind of entity. That's not true, as long as I found you need to have as many indexes as different queries you will need to make.

    • While on development web server indexes are autogenerated and placed below the #AUTOGENERATED line in index.yaml file.

    • After modifying indexes I use first gcloud datastore indexes create index.yaml and I wait until indexes are Serving in https://console.cloud.google.com/datastore/indexes?project=your-project.

    • I clean unused indexes by executing gcloud datastore indexes cleanup index.yaml be aware that you do not delete indexes that are being used on production. Reference here

    • Be aware that if you don't specify direction on your index properties, it will be ASC by default. So if you are trying to make a - sort query it will again rise the error.

    Things I think but I have not 100% evidence longer than my particular problem, but I think can help as a kind of brainstorming:

    • Indexes are important while querying data, not when uploading.

    • Creating manually the #AUTOGENERATED line not seem to be necessary if you are generating indexes manually. Reference here

    • As the development server updates indexes below #AUTOGENERATED line while making queries, you can "accidentally" solve your problem by adding this lane. While the real problem is a lack of manually index update using gcloud datastore indexes create index.yaml command. Reference here and here

    0 讨论(0)
  • 2020-12-15 19:36

    In my case, I have uploaded the index file manually like below:

    gcloud datastore indexes create "C:\Path\of\your\project\index.yaml"
    

    Then you should confirm the update:

    Configurations to update:
    
    descriptor:      [C:\Path\of\your\project\index.yaml]
    type:            [datastore indexes]
    target project:  [project_name]
    
    
    Do you want to continue (Y/n)?  y
    

    Then you can go to the Datastore console to check if the the index has been created via this link: https://console.cloud.google.com/datastore/indexes

    0 讨论(0)
提交回复
热议问题