0

실행중인 앱이 ViewDog에 대한 요청을 처리 할 때 내부 서버 오류가 발생합니다.GAE NeedIndexError :

NeedIndexError: no matching index found - recommended index is: 
- kind:Dog 
    ancestor: yes 
    properties: - 
    name: id 
    direction: desc". 

내가 개라는 이름의로드 된 인덱스가 확인하고는 현재

이 또한 확인

4 개를 성공적으로 만들어, 그들은에서 조회 할 수있다 "봉사"보여줍니다 GAE 스택 드라이버 콘솔에서 내가 얻을 데이터 저장소 엔터티 탭을 개별적으로 선택하고 SELECT * FROM Dog를 사용합니다. 또한 주석 처리 된 행 self.response.write('You dog!')이 주석 처리되지 않은 경우 예상대로 반환되므로 경로 문제가 아닐 수 있습니다. GET (이 코드 생략)을 통해 하나의 개를 반환 할 수 있습니다. ViewAllDogs 클래스의 코드가 잘못되어 GAE 문서에 최선을 다했습니다. 내가 확인

index.yaml 파일 업로드 및 상태가된다

indexes: 
- kind: Dog 
    ancestor: yes 
    properties:- name: id 
    direction: desc 
    - name: name 
    direction: desc 
    - name: type 
    direction: desc 
    - name: weight 
    direction: desc 
    - name: boarded 
    direction: desc 

애플리케이션 제목 파일 "봉사"

runtime: python27 
api_version: 1 
threadsafe: true 

handlers: 
- url: /.* 
    script: main.app 

main.py

import webapp2 
from datetime import datetime 
from google.appengine.ext import ndb 
import webbrowser 
import json 

def gql_json_parser(query_obj): 
    result = [] 
    for entry in query_obj: 
     result.append(dict([(p, unicode(getattr(entry, p))) for p in entry.properties()])) 
    return result 

class Dog(ndb.Model): 
    """ Models an individual Dog """ 
    id = ndb.StringProperty(required = True, indexed = True) 
    name = ndb.StringProperty(required = True, indexed = True) 
    type = ndb.StringProperty(required = True, indexed = True) 
    weight = ndb.IntegerProperty(required = True, indexed = True) 
    boarded = ndb.BooleanProperty(required = True, indexed = True) 

    @classmethod 
    def query_dog(cls, ancestor_key): 
     return cls.query(ancestor=ancestor_key).order(-cls.id) 

class ViewAllDogs(webapp2.RequestHandler): 
    def get(self): 
#  self.response.write('You dog!') 
     parent_dog = self.request.get('parent_dog') 
     ancestor_key = ndb.Key("Dog", parent_dog or '*noDogs*') 
     query_data = Dog.query_dog(ancestor_key).fetch(10) 
     json_query_data = gql_json_parser(query_data) 
     self.response.headers['Content-Type'] = 'application/json' 
     self.response.write(json.dumps(json_query_data)) 

app = webapp2.WSGIApplication([ 
    ('/ViewDogs', ViewAllDogs) 
], debug=True) 

을 비슷한 질문이 많으며이 Query google app engine datastore for all entities을 포함하지만 내 문제를 해결하는 사람은 아무도 없습니다. 감사.

+1

... 훨씬 더 복잡 할 필요 이상으로 만들고 있었다. 필요한 색인은 정확히 필요한 색인이어야합니다. –

+0

몇 분 후에 다시 시도해 보셨습니까? 쿼리 또는 데이터 구조를 변경하면 데이터 저장소 인덱스는 배포 후 업데이트하는 데 몇 분이 걸릴 수 있습니다 (데이터 크기에 따라 여러 개가 될 수 있음). 프로덕션 환경에서는'--no-promote' 플래그를 사용하고 인덱스가 업데이트 될 때까지 기다린 후 트래픽을 새 버전으로 배포 할 수 있습니다. –

답변

0

평소와 같이, 나는 누락 지수는 사용자가 정의한 인덱스에 다른 사항

import webapp2, json 
from datetime import datetime 
from google.appengine.ext import ndb 

MAXDOGS = 100 

class Dog(ndb.Model): 
    """ Models an individual Dog """ 
    id = ndb.StringProperty(required = True, indexed = True) 
    name = ndb.StringProperty(required = True, indexed = True) 
    type = ndb.StringProperty(required = True, indexed = True) 
    weight = ndb.IntegerProperty(required = True, indexed = True) 
    boarded = ndb.BooleanProperty(required = True, indexed = True) 

class ViewAllDogs(webapp2.RequestHandler): 
    def get(self): 
     query_data = Dog.query() 
     results = query.fetch(limit = MAX_SLIPS) 
     aList = [] 
     for match in results: 
      aList.append({'id': match.id, 'name': match.name, 'type': match.type, 
          'weight': match.weight, 'boarded': match.boarded}) 
     self.response.headers['Content-Type'] = 'application/json' 
     self.response.write(json.dumps(aList)) 

app = webapp2.WSGIApplication([ 
    ('/ViewDogs', ViewAllDogs)