Python 2.7은 지원이 종료되었으며 2026년 1월 31일에 지원 중단됩니다. 지원 중단 후에는 조직에서 이전에 조직 정책을 사용하여 레거시 런타임의 배포를 다시 사용 설정한 경우에도 Python 2.7 애플리케이션을 배포할 수 없습니다. 기존 Python 2.7 애플리케이션은 지원 중단 날짜 이후에도 계속 실행되고 트래픽을 수신합니다. 지원되는 최신 Python 버전으로 마이그레이션하는 것이 좋습니다.
Datastore 모드의 Firestore(Datastore)를 사용하여 표준 환경에서 실행되는 애플리케이션의 데이터를 저장할 수 있습니다. Datastore는 애플리케이션에서 생성되는 모든 쿼리에 색인을 사용합니다. 항목이 변경될 때마다 색인이 업데이트되면 앱에서 쿼리를 만들 때 결과가 신속하게 반환됩니다. 이를 위해 Datastore는 애플리케이션이 생성할 쿼리를 미리 알아야 합니다. 사용자는 index.yaml 구성 파일에서 앱에 필요한 색인을 지정합니다. Datastore 에뮬레이터를 사용하여 앱을 테스트하는 동안에 파일을 자동으로 생성하거나 직접 작성할 수 있습니다. index.yaml 파일은 앱을 배포할 때 업로드되어야 합니다.
index.yaml 정보
애플리케이션이 실행하는 모든 Datastore 쿼리에는 상응하는 색인이 필요합니다. 단일 속성 쿼리처럼 단순한 쿼리의 색인은 자동으로 생성됩니다. 복잡한 쿼리의 색인은 index.yaml이라는 구성 파일에 정의되어야 합니다. 이 파일은 애플리케이션과 함께 업로드되어 Datastore에서 색인을 만듭니다.
--data-dir 플래그를 사용하여 자동 생성된 index.yaml 파일을 표시할 디렉터리를 지정합니다.
앱을 테스트하는 동안 Datastore 쿼리를 생성할 때마다 에뮬레이터가 생성된 색인 정의를 index.yaml에 추가합니다. 자동으로 생성된 모든 색인 정의는 다음 줄 아래에 파일로 표시됩니다.
# AUTOGENERATED
이 줄 위의 모든 색인 정의는 수동 제어되는 것으로 인식되어 개발용 웹 서버에서 업데이트하지 않습니다. 웹 서버는 이 줄 아래의 내용만 변경하는데 애플리케이션이 실행하는 쿼리의 색인이 완성된 index.yaml 파일에 명시되지 않은 경우에만 이러한 변경 작업을 수행합니다. 자동 색인 정의를 제어하려면 색인을 이 줄 위로 옮깁니다.
애플리케이션이 쿼리를 생성하는 동안에 에뮬레이터가 이 줄 아래의 기존 정의를 업데이트할 수 있습니다. 앱을 테스트하는 동안 앱이 실행할 모든 쿼리를 생성하면 index.yaml 내의 생성 항목이 완료됩니다. 이 파일을 수동으로 편집하여 프로덕션에서 사용되지 않는 색인을 삭제하거나 테스트하는 동안 생성되지 않은 색인을 정의해야 할 수도 있습니다.
색인 구성 파일 배포
index.yaml 구성 파일을 배포하려면 다음 명령어를 실행합니다.
gcloudappdeployindex.yaml
미사용 색인 삭제
색인 구성에서 색인을 변경하거나 삭제해도 원본 색인이 App Engine에서 자동으로 삭제되지 않습니다. 그렇기 때문에 이전 버전의 앱을 실행 중인 상태로 유지하면서 새 색인을 빌드하거나, 새 버전에 문제가 발견된 경우 즉시 이전 버전으로 되돌릴 수 있습니다.
이전 색인이 더 이상 필요하지 않으면 다음과 같이 App Engine에서 색인을 삭제할 수 있습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eDatastore requires indexes for every query, with simple query indexes created automatically and complex query indexes defined in an \u003ccode\u003eindex.yaml\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eindex.yaml\u003c/code\u003e file, which is necessary for defining complex queries, must be uploaded when deploying an application to ensure the indexes are available in Datastore.\u003c/p\u003e\n"],["\u003cp\u003eYou can automatically generate the \u003ccode\u003eindex.yaml\u003c/code\u003e file by using the Datastore emulator during local testing, which will add index definitions as you run your application and generate queries.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eindex.yaml\u003c/code\u003e file has a clear separation between manually controlled index definitions and automatically generated ones, with the \u003ccode\u003e# AUTOGENERATED\u003c/code\u003e line indicating where automatic updates occur.\u003c/p\u003e\n"],["\u003cp\u003eUnused indexes in App Engine can be manually deleted using the \u003ccode\u003egcloud datastore indexes cleanup index.yaml\u003c/code\u003e command, which is necessary after changing or removing index definitions in the \u003ccode\u003eindex.yaml\u003c/code\u003e file.\u003c/p\u003e\n"]]],[],null,["# Configuring Datastore Indexes with index.yaml\n\nYou can use [Firestore in Datastore mode (Datastore)](/appengine/docs/legacy/standard/python/using-cloud-datastore)\nfor storing data for your applications that run in the standard\nenvironment. Datastore uses\n[indexes](/datastore/docs/concepts/indexes)\nfor every query your application makes. These indexes are updated whenever an\nentity changes, so the results can be returned quickly when the app makes a\nquery. To do this, Datastore needs to know in advance which\nqueries the application will make. You specify which indexes your app needs in a\n`index.yaml` configuration file. You can use the Datastore\nemulator to generate the file automatically as you test your app, or write the\nfile yourself. The `index.yaml` file must be uploaded when you deploy your app.\n\nAbout `index.yaml`\n------------------\n\nEvery Datastore query made by an application needs a\ncorresponding index. Indexes for simple queries, such as queries over a single\nproperty, are created automatically. Indexes for complex queries must be defined\nin a configuration file named `index.yaml`. This file is uploaded with the\napplication to create indexes in Datastore.\n\nThe following is an example of an `index.yaml` file: \n\n indexes:\n\n - kind: Cat\n ancestor: no\n properties:\n - name: name\n - name: age\n direction: desc\n\n - kind: Cat\n properties:\n - name: name\n direction: asc\n - name: whiskers\n direction: desc\n\n - kind: Store\n ancestor: yes\n properties:\n - name: business\n direction: asc\n - name: owner\n direction: asc\n\nThe syntax of `index.yaml` is the YAML format. For more information about this\nsyntax, see [the YAML website](http://www.yaml.org/) for more information.\n| **Note:** The YAML format supports comments. A line that begins with a pound (`#`) character is ignored: \n| `# This is a comment.`\n\nIndex definitions\n-----------------\n\n`index.yaml` has a single list element called `indexes`. Each element in the\nlist represents an index for the application.\n\nAn index element can have the following elements:\n\n`kind`\n: The kind of the entity for the query. Typically, this\n is the name of the [Model](/appengine/docs/legacy/standard/python/datastore/modelclass)\n class that defines the model for the entities. This element is required.\n\n`properties`\n\n: A list of properties to include as columns of the index, in the order to be\n sorted: properties used in equality filters first, followed by the property used\n in inequality filters, then the sort orders and their directions.\n\n Each element in this list has the following elements:\n\n `name`\n : The datastore name of the property.\n\n `direction`\n : The direction to sort, either `asc` for ascending or `desc` for descending. This is only required for properties used in sort orders of the query, and must match the direction used by the query. The default is `asc`.\n\n`ancestor`\n\n: `yes` if the query has an ancestor clause (either [Query.ancestor()](/appengine/docs/legacy/standard/python/datastore/queryclass#Query_ancestor) or a GQL [ANCESTOR IS](/appengine/docs/legacy/standard/python/datastore/gqlreference) clause). The default is `no`.\n\nCreating index files\n--------------------\n\nYou can create an index file manually, using a text editor and following the\nfile layout described above. A more efficient approach is to automatically\ngenerate the file as you test your app locally. You can combine the two methods.\n\nWhen you are testing in your local environment, you can use the\n[gcloud emulator command](/sdk/gcloud/reference/beta/emulators/datastore/start)\nto start a service that emulates Datastore before you run your\napp: \n\n gcloud beta emulators datastore start --data-dir DATA-DIR\n\nUse the `--data-dir` flag to specify the directory where the auto-generated\n`index.yaml` file will appear.\n\nAs you test your app, each time you generate a Datastore query,\nthe emulator adds a generated index definition to `index.yaml`. All the\nautomatically generated index definitions will appear in the file below the\nfollowing line: \n\n # AUTOGENERATED\n\nAll index definitions above this line are considered to be under manual\ncontrol, and are not updated by the development web server. The web server\nwill only make changes below the line, and will only do so if the complete\n`index.yaml` file does not describe an index that accounts for a query executed\nby the application. To take control of an automatic index definition, move it\nabove this line.\n\nThe emulator may update existing definitions below this line as the application\nmakes queries. If the app generates every query it will make while you test it,\nthen the generated entries in `index.yaml` will be complete. You might need to\nedit the file manually to delete indexes that are not used in production, or to\ndefine indexes that were not created while testing.\n\nDeploying the index configuration file\n--------------------------------------\n\nTo deploy the `index.yaml` configuration file, run the following command:\n\n\u003cbr /\u003e\n\n gcloud app deploy index.yaml\n\nDeleting unused indexes\n-----------------------\n\nWhen you change or remove an index from the index configuration, the original\nindex is not deleted from App Engine automatically. This gives you the\nopportunity to leave an older version of the app running while new indexes are\nbeing built, or to revert to the older version immediately if a problem is\ndiscovered with a newer version.\n\nWhen you are sure that old indexes are no longer needed, you can delete them\nfrom App Engine as follows: \n\n gcloud datastore indexes cleanup index.yaml"]]