# Class PipelineSource (3.43.1)

3.43.1 (latest) 3.41.0 3.38.0 3.37.0 3.36.0 3.35.1 3.33.4 3.32.2 3.31.9 3.30.11 3.28.0 3.27.2 3.26.5 3.25.1 3.24.3 3.22.0 3.21.4 3.20.0 3.17.0 3.16.3 3.15.7 3.14.4 3.13.2 3.12.1 3.11.0 3.10.0 3.9.6 3.8.2 3.7.10 3.6.0 3.5.0 3.4.2 3.3.0 3.2.0 3.1.0 3.0.21

    public final class PipelineSource

A factory for creating [Pipeline](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline) instances, which provide a framework for building data
transformation and query pipelines for Firestore.

Start by calling [Firestore#pipeline()](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Firestore#com_google_cloud_firestore_Firestore_pipeline__) to obtain an instance of `PipelineSource`.
From there, you can use the provided methods (like [#collection(String)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.PipelineSource#com_google_cloud_firestore_PipelineSource_collection_java_lang_String_)) to specify the
data source for your pipeline.

This class is typically used to start building Firestore pipelines. It allows you to define
the initial data source for a pipeline.

Example Usage:


     firestore.pipeline() // Get a PipelineSource instance
       .collection("users") // Create a pipeline that operates on a collection
       .select("name"); // Add stages to the pipeline
     
## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> PipelineSource

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Methods

### subcollection(String path)

    public static Pipeline subcollection(String path)

Initializes a pipeline scoped to a subcollection.

This method allows you to start a new pipeline that operates on a subcollection of the
current document. It is intended to be used as a subquery.

**Note:** A pipeline created with `subcollection` cannot be executed directly using
[Pipeline#execute()](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline#com_google_cloud_firestore_Pipeline_execute__). It must be used within a parent pipeline.

Example:


     firestore.pipeline().collection("books")
         .addFields(
             PipelineSource.subcollection("reviews")
                 .aggregate(AggregateFunction.average("rating").as("avg_rating"))
                 .toScalarExpression().as("average_rating"));
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `path` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` The path of the subcollection. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline` | A new `Pipeline` instance scoped to the subcollection. |

## Methods

### collection(CollectionReference ref)

    public Pipeline collection(CollectionReference ref)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `ref` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.CollectionReference` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline` |   |

### collection(String path)

    public Pipeline collection(String path)

Creates a new [Pipeline](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline) that operates on the specified Firestore collection.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `path` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` The path to the Firestore collection (e.g., "users"). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline` | A new `Pipeline` instance targeting the specified collection. |

### collection(String path, CollectionOptions options)

    public Pipeline collection(String path, CollectionOptions options)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `path` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `options` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.pipeline.stages.CollectionOptions` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline` |   |

### collectionGroup(String collectionId)

    public Pipeline collectionGroup(String collectionId)

Creates a new [Pipeline](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline) that operates on all documents in a collection group.

A collection group consists of all collections with the same ID. For example, if you have
collections named "users" under different documents, you can query them together using a
collection group query.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `collectionId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` The ID of the collection group. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline` | A new `Pipeline` instance targeting the specified collection group. |

### collectionGroup(String collectionId, CollectionGroupOptions options)

    public Pipeline collectionGroup(String collectionId, CollectionGroupOptions options)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `collectionId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `options` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.pipeline.stages.CollectionGroupOptions` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline` |   |

### createFrom(AggregateQuery query)

    public Pipeline createFrom(AggregateQuery query)

Creates a new [Pipeline](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline) from the given [AggregateQuery](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.AggregateQuery). Under the hood, this will
translate the query semantics (order by document ID, etc.) to an equivalent pipeline.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `query` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.AggregateQuery` The [AggregateQuery](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.AggregateQuery) to translate into the resulting pipeline. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline` | A new `Pipeline` that is equivalent to the given query. |

### createFrom(Query query)

    public Pipeline createFrom(Query query)

Creates a new [Pipeline](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline) from the given [Query](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Query). Under the hood, this will
translate the query semantics (order by document ID, etc.) to an equivalent pipeline.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `query` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Query` The [Query](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Query) to translate into the resulting pipeline. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline` | A new `Pipeline` that is equivalent to the given query. |

### database()

    public Pipeline database()

Creates a new [Pipeline](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline) that operates on all documents in the Firestore database.

Use this method with caution as it can lead to very large result sets. It is usually only
useful at development stage.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline` | A new `Pipeline` instance targeting all documents in the database. |

### documents(DocumentReference\[\] docs)

    public Pipeline documents(DocumentReference[] docs)

Creates a new [Pipeline](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline) that operates on a specific set of Firestore documents.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `docs` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentReference[]` The [DocumentReference](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentReference) instances representing the documents to include in the pipeline. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline` | A new `Pipeline` instance targeting the specified documents. |

### documents(String\[\] docs)

    public Pipeline documents(String[] docs)

Creates a new [Pipeline](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline) that operates on a specific set of Firestore documents.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `docs` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html[]` The [DocumentReference](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentReference) instances representing the documents to include in the pipeline. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline` | A new `Pipeline` instance targeting the specified documents. |

### literals(Map\<String,Object\>\[\] data)

    public final Pipeline literals(Map<String,Object>[] data)

Creates a new [Pipeline](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline) that operates on a static set of documents represented as Maps.

Example:


     Map<String, Object> doc1 = new HashMap<>();
     doc1.put("title", "Book 1");
     Map<String, Object> doc2 = new HashMap<>();
     doc2.put("title", "Book 2");

     Snapshot snapshot = firestore.pipeline()
         .literals(doc1, doc2)
         .execute()
         .get();
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `data` | `https://docs.oracle.com/javase/8/docs/api/java/util/Map.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html,https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html>[]` The Maps representing documents to include in the pipeline. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.Pipeline` | A new `Pipeline` instance with a literals source. |