The order to apply to the query results. Firestore guarantees a stable ordering through the following rules: * * Any field required to appear inorder_by, that is not already specified inorder_by, is appended to the order in field name order by default. * * If an order on__name__is not specified, it is appended by default. Fields are appended with the same sort direction as the last order specified, or 'ASCENDING' if no order was specified. For example: * *SELECT * FROM Foo ORDER BY AbecomesSELECT * FROM Foo ORDER BY A, __name__* *SELECT * FROM Foo ORDER BY A DESCbecomesSELECT * FROM Foo ORDER BY A DESC, __name__ DESC* *SELECT * FROM Foo WHERE A > 1becomesSELECT * FROM Foo WHERE A > 1 ORDER BY A, __name__
Firestore guarantees a stable ordering through the following rules:
Any field required to appear inorder_by, that is not already
specified inorder_by, is appended to the order in field name order
by default.
If an order on__name__is not specified, it is appended by default.
Fields are appended with the same sort direction as the last order
specified, or 'ASCENDING' if no order was specified. For example:
SELECT * FROM Foo ORDER BY AbecomesSELECT * FROM Foo ORDER BY A, __name__
SELECT * FROM Foo ORDER BY A DESCbecomesSELECT * FROM Foo ORDER BY A DESC, __name__ DESC
SELECT * FROM Foo WHERE A > 1becomesSELECT * FROM Foo WHERE A > 1 ORDER BY A, __name__
Firestore guarantees a stable ordering through the following rules:
Any field required to appear inorder_by, that is not already
specified inorder_by, is appended to the order in field name order
by default.
If an order on__name__is not specified, it is appended by default.
Fields are appended with the same sort direction as the last order
specified, or 'ASCENDING' if no order was specified. For example:
SELECT * FROM Foo ORDER BY AbecomesSELECT * FROM Foo ORDER BY A, __name__
SELECT * FROM Foo ORDER BY A DESCbecomesSELECT * FROM Foo ORDER BY A DESC, __name__ DESC
SELECT * FROM Foo WHERE A > 1becomesSELECT * FROM Foo WHERE A > 1 ORDER BY A, __name__
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud Firestore V1beta1 Client - Class StructuredQuery (1.53.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.53.0 (latest)](/php/docs/reference/cloud-firestore/latest/V1beta1.StructuredQuery)\n- [1.52.0](/php/docs/reference/cloud-firestore/1.52.0/V1beta1.StructuredQuery)\n- [1.51.0](/php/docs/reference/cloud-firestore/1.51.0/V1beta1.StructuredQuery)\n- [1.50.0](/php/docs/reference/cloud-firestore/1.50.0/V1beta1.StructuredQuery)\n- [1.48.1](/php/docs/reference/cloud-firestore/1.48.1/V1beta1.StructuredQuery)\n- [1.47.3](/php/docs/reference/cloud-firestore/1.47.3/V1beta1.StructuredQuery)\n- [1.46.0](/php/docs/reference/cloud-firestore/1.46.0/V1beta1.StructuredQuery)\n- [1.45.2](/php/docs/reference/cloud-firestore/1.45.2/V1beta1.StructuredQuery)\n- [1.44.1](/php/docs/reference/cloud-firestore/1.44.1/V1beta1.StructuredQuery)\n- [1.43.3](/php/docs/reference/cloud-firestore/1.43.3/V1beta1.StructuredQuery)\n- [1.40.0](/php/docs/reference/cloud-firestore/1.40.0/V1beta1.StructuredQuery)\n- [1.39.0](/php/docs/reference/cloud-firestore/1.39.0/V1beta1.StructuredQuery)\n- [1.38.0](/php/docs/reference/cloud-firestore/1.38.0/V1beta1.StructuredQuery)\n- [1.37.7](/php/docs/reference/cloud-firestore/1.37.7/V1beta1.StructuredQuery)\n- [1.36.1](/php/docs/reference/cloud-firestore/1.36.1/V1beta1.StructuredQuery)\n- [1.35.0](/php/docs/reference/cloud-firestore/1.35.0/V1beta1.StructuredQuery)\n- [1.34.0](/php/docs/reference/cloud-firestore/1.34.0/V1beta1.StructuredQuery)\n- [1.33.0](/php/docs/reference/cloud-firestore/1.33.0/V1beta1.StructuredQuery)\n- [1.32.0](/php/docs/reference/cloud-firestore/1.32.0/V1beta1.StructuredQuery)\n- [1.31.0](/php/docs/reference/cloud-firestore/1.31.0/V1beta1.StructuredQuery)\n- [1.30.0](/php/docs/reference/cloud-firestore/1.30.0/V1beta1.StructuredQuery)\n- [1.28.0](/php/docs/reference/cloud-firestore/1.28.0/V1beta1.StructuredQuery)\n- [1.27.3](/php/docs/reference/cloud-firestore/1.27.3/V1beta1.StructuredQuery) \n| **Beta**\n|\n|\n| This library is covered by the [Pre-GA Offerings Terms](/terms/service-terms#1)\n| of the Terms of Service. Pre-GA libraries might have limited support,\n| and changes to pre-GA libraries might not be compatible with other pre-GA versions.\n| For more information, see the\n[launch stage descriptions](/products#product-launch-stages). \nReference documentation and code samples for the Cloud Firestore V1beta1 Client class StructuredQuery.\n\nA Firestore query.\n\nGenerated from protobuf message `google.firestore.v1beta1.StructuredQuery`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Firestore \\\\ V1beta1\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getSelect\n\nThe projection to return.\n\n### setSelect\n\nThe projection to return.\n\n### getFrom\n\nThe collections to query.\n\n### setFrom\n\nThe collections to query.\n\n### getWhere\n\nThe filter to apply.\n\n### setWhere\n\nThe filter to apply.\n\n### getOrderBy\n\nThe order to apply to the query results.\n\nFirestore guarantees a stable ordering through the following rules:\n\n- Any field required to appear in `order_by`, that is not already specified in `order_by`, is appended to the order in field name order by default.\n- If an order on `__name__` is not specified, it is appended by default. Fields are appended with the same sort direction as the last order specified, or 'ASCENDING' if no order was specified. For example:\n- `SELECT * FROM Foo ORDER BY A` becomes `SELECT * FROM Foo ORDER BY A, __name__`\n- `SELECT * FROM Foo ORDER BY A DESC` becomes `SELECT * FROM Foo ORDER BY A DESC, __name__ DESC`\n- `SELECT * FROM Foo WHERE A \u003e 1` becomes `SELECT * FROM Foo WHERE A \u003e 1 ORDER BY A, __name__`\n\n### setOrderBy\n\nThe order to apply to the query results.\n\nFirestore guarantees a stable ordering through the following rules:\n\n- Any field required to appear in `order_by`, that is not already specified in `order_by`, is appended to the order in field name order by default.\n- If an order on `__name__` is not specified, it is appended by default. Fields are appended with the same sort direction as the last order specified, or 'ASCENDING' if no order was specified. For example:\n- `SELECT * FROM Foo ORDER BY A` becomes `SELECT * FROM Foo ORDER BY A, __name__`\n- `SELECT * FROM Foo ORDER BY A DESC` becomes `SELECT * FROM Foo ORDER BY A DESC, __name__ DESC`\n- `SELECT * FROM Foo WHERE A \u003e 1` becomes `SELECT * FROM Foo WHERE A \u003e 1 ORDER BY A, __name__`\n\n### getStartAt\n\nA starting point for the query results.\n\n### setStartAt\n\nA starting point for the query results.\n\n### getEndAt\n\nA end point for the query results.\n\n### setEndAt\n\nA end point for the query results.\n\n### getOffset\n\nThe number of results to skip.\n\nApplies before limit, but after all other constraints. Must be \\\u003e= 0 if\nspecified.\n\n### setOffset\n\nThe number of results to skip.\n\nApplies before limit, but after all other constraints. Must be \\\u003e= 0 if\nspecified.\n\n### getLimit\n\nThe maximum number of results to return.\n\nApplies after all other constraints.\nMust be \\\u003e= 0 if specified.\n\n### getLimitValue\n\nReturns the unboxed value from `getLimit()`\n\nThe maximum number of results to return.\nApplies after all other constraints.\nMust be \\\u003e= 0 if specified.\n\n### setLimit\n\nThe maximum number of results to return.\n\nApplies after all other constraints.\nMust be \\\u003e= 0 if specified.\n\n### setLimitValue\n\nSets the field by wrapping a primitive type in a Google\\\\Protobuf\\\\Int32Value object.\n\nThe maximum number of results to return.\nApplies after all other constraints.\nMust be \\\u003e= 0 if specified."]]