Python 2.7은 지원이 종료되었으며 2026년 1월 31일에
지원 중단됩니다. 지원 중단 후에는 조직에서 이전에 조직 정책을 사용하여 레거시 런타임의 배포를 다시 사용 설정한 경우에도 Python 2.7 애플리케이션을 배포할 수 없습니다. 기존 Python 2.7 애플리케이션은
지원 중단 날짜 이후에도 계속 실행되고 트래픽을 수신합니다.
지원되는 최신 Python 버전으로 마이그레이션하는 것이 좋습니다.
SortExpression 클래스
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
SortExpression
클래스를 사용하면 검색 결과의 정렬 방식을 맞춤 설정할 수 있습니다.
SortExpression
은 google.appengine.api.search
모듈에 정의됩니다.
생성자
SortExpression
클래스의 생성자는 다음과 같이 정의됩니다.
-
class SortExpression(expression=None, direction=DESCENDING, default_value=None)
지정된 점수 매기기 식을 기준으로 결과를 정렬합니다.
인수
- expression
일치하는 각 문서 결과 정렬 시 평가할 표현식입니다. 이 표현식은 단순히 필드 이름이거나 점수 처리기의 점수를 0.1 계수로 가중치를 적용한 likes
필드의 값 카운트에 추가하는 _score + count(likes) * 0.1
과 같은 일부 복합 표현식일 수 있습니다.
- direction
검색 결과를 정렬할 방향으로, ASCENDING 또는 DESCENDING입니다.
- default_value
문서에 필드가 없고 필드를 계산할 수 없는 경우의 표현식 기본값입니다. 텍스트 정렬의 경우 텍스트 값을 지정해야 합니다. 숫자 정렬의 경우, 숫자 값을 지정해야 합니다.
결과 값
SortExpression
클래스의 새 인스턴스입니다.
예외
- TypeError
매개변수에 잘못된 유형이 있거나 알 수 없는 속성이 전달된 경우 발생합니다.
- ValueError
매개변수에 잘못된 값이 있는 경우 발생합니다.
속성
SortExpression
클래스의 인스턴스에는 다음 속성이 있습니다.
- expression
일치하는 결과를 정렬하는 데 사용되는 식을 반환합니다.
- direction
ASCENDING
또는 DESCENDING
중에서 정렬 식의 방향을 반환합니다.
- default_value
다른 값을 계산할 수 없는 경우, 식의 기본값을 반환합니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-09-04(UTC)
[[["이해하기 쉬움","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\u003eThe \u003ccode\u003eSortExpression\u003c/code\u003e class enables customization of search result sorting using an expression.\u003c/p\u003e\n"],["\u003cp\u003eIt can be used with first-generation runtimes and is applicable when upgrading to second-generation runtimes.\u003c/p\u003e\n"],["\u003cp\u003eThe class constructor accepts \u003ccode\u003eexpression\u003c/code\u003e, \u003ccode\u003edirection\u003c/code\u003e (\u003ccode\u003eASCENDING\u003c/code\u003e or \u003ccode\u003eDESCENDING\u003c/code\u003e), and \u003ccode\u003edefault_value\u003c/code\u003e to define how results are sorted.\u003c/p\u003e\n"],["\u003cp\u003eProperties \u003ccode\u003eexpression\u003c/code\u003e, \u003ccode\u003edirection\u003c/code\u003e, and \u003ccode\u003edefault_value\u003c/code\u003e can be retrieved from an instance of \u003ccode\u003eSortExpression\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# The SortExpression Class\n\nClass `SortExpression` allows you to customize how your search results are sorted.\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| python3\n|\n| /services/access). If you are updating to the App Engine Python 3 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/python-differences) to learn about your migration options for legacy bundled services.\n\n`SortExpression` is defined in the `google.appengine.api.search` module.\n\nConstructor\n-----------\n\nThe constructor for class `SortExpression` is defined as follows:\n\n\nclass SortExpression(expression=None, direction=DESCENDING, default_value=None)\n\n:\n Sort results by the specified scoring expression.\n\n:\n\n Arguments\n\n expression\n\n : An expression to be evaluated when sorting results for each matching document. The expression can simply be a field name, or some compound expression such as\n `_score + count(likes) * 0.1`\n which will add the score from a scorer to a count of the values of a\n `likes` field weighted by a factor of 0.1.\n\n direction\n\n : The direction to sort the search results, either ASCENDING or DESCENDING.\n\n default_value\n\n : The default value of the expression, if no field is present and cannot be calculated for a document. A text value must be specified for text sorts. A numeric value must be specified for numeric sorts.\n\n Result value\n\n : A new instance of class `SortExpression`.\n\n Exceptions\n\n TypeError\n\n : If any of the parameters have an invalid type, or an unknown attribute is passed.\n\n ValueError\n\n : If any parameter has an invalid value.\n\n \u003cbr /\u003e\n\nProperties\n----------\n\nAn instance of class `SortExpression` has the following properties:\n\nexpression\n\n: Returns the expression used to sort matched results.\n\ndirection\n\n: Returns the direction of sort expression: `ASCENDING` or `DESCENDING`.\n\ndefault_value\n\n: Returns a default value for the expression if no other value could be computed."]]