google-cloud-firestore
diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java
index 5443b7513f..363046c39c 100644
--- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java
+++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java
@@ -1228,6 +1228,134 @@ public static BooleanExpression regexContains(String fieldName, String pattern)
return regexContains(field(fieldName), constant(pattern));
}
+ /**
+ * Creates an expression that returns the first substring of a string expression that matches a
+ * specified regular expression.
+ *
+ * This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
+ * syntax.
+ *
+ * @param string The expression representing the string to search.
+ * @param pattern The regular expression to search for.
+ * @return A new {@link Expression} representing the regular expression find function.
+ */
+ @BetaApi
+ public static Expression regexFind(Expression string, Expression pattern) {
+ return new FunctionExpression("regex_find", ImmutableList.of(string, pattern));
+ }
+
+ /**
+ * Creates an expression that returns the first substring of a string expression that matches a
+ * specified regular expression.
+ *
+ *
This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
+ * syntax.
+ *
+ * @param string The expression representing the string to search.
+ * @param pattern The regular expression to search for.
+ * @return A new {@link Expression} representing the regular expression find function.
+ */
+ @BetaApi
+ public static Expression regexFind(Expression string, String pattern) {
+ return regexFind(string, constant(pattern));
+ }
+
+ /**
+ * Creates an expression that returns the first substring of a string field that matches a
+ * specified regular expression.
+ *
+ *
This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
+ * syntax.
+ *
+ * @param fieldName The name of the field containing the string to search.
+ * @param pattern The regular expression to search for.
+ * @return A new {@link Expression} representing the regular expression find function.
+ */
+ @BetaApi
+ public static Expression regexFind(String fieldName, Expression pattern) {
+ return regexFind(field(fieldName), pattern);
+ }
+
+ /**
+ * Creates an expression that returns the first substring of a string field that matches a
+ * specified regular expression.
+ *
+ *
This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
+ * syntax.
+ *
+ * @param fieldName The name of the field containing the string to search.
+ * @param pattern The regular expression to search for.
+ * @return A new {@link Expression} representing the regular expression find function.
+ */
+ @BetaApi
+ public static Expression regexFind(String fieldName, String pattern) {
+ return regexFind(field(fieldName), constant(pattern));
+ }
+
+ /**
+ * Creates an expression that evaluates to a list of all substrings in a string expression that
+ * match a specified regular expression.
+ *
+ *
This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
+ * syntax.
+ *
+ * @param string The expression representing the string to search.
+ * @param pattern The regular expression to search for.
+ * @return A new {@link Expression} that evaluates to a list of matched substrings.
+ */
+ @BetaApi
+ public static Expression regexFindAll(Expression string, Expression pattern) {
+ return new FunctionExpression("regex_find_all", ImmutableList.of(string, pattern));
+ }
+
+ /**
+ * Creates an expression that evaluates to a list of all substrings in a string expression that
+ * match a specified regular expression.
+ *
+ *
This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
+ * syntax.
+ *
+ * @param string The expression representing the string to search.
+ * @param pattern The regular expression to search for.
+ * @return A new {@link Expression} that evaluates to a list of matched substrings.
+ */
+ @BetaApi
+ public static Expression regexFindAll(Expression string, String pattern) {
+ return regexFindAll(string, constant(pattern));
+ }
+
+ /**
+ * Creates an expression that evaluates to a list of all substrings in a string field that match a
+ * specified regular expression.
+ *
+ *
This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
+ * syntax.
+ *
+ * @param fieldName The name of the field containing the string to search.
+ * @param pattern The regular expression to search for.
+ * @return A new {@link Expression} that evaluates to a list of matched substrings.
+ */
+ @BetaApi
+ public static Expression regexFindAll(String fieldName, Expression pattern) {
+ return regexFindAll(field(fieldName), pattern);
+ }
+
+ /**
+ * Creates an expression that evaluates to a list of all substrings in a string field that match a
+ * specified regular expression.
+ *
+ *
This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
+ * syntax.
+ *
+ * @param fieldName The name of the field containing the string to search.
+ * @param pattern The regular expression to search for.
+ * @return A new {@link Expression} that evaluates to a list of matched substrings.
+ */
+ @BetaApi
+ public static Expression regexFindAll(String fieldName, String pattern) {
+ return regexFindAll(field(fieldName), constant(pattern));
+ }
+
/**
* Creates an expression that checks if a string field matches a specified regular expression.
*
@@ -3872,6 +4000,36 @@ public final BooleanExpression regexContains(Object pattern) {
return regexContains(this, toExprOrConstant(pattern));
}
+ /**
+ * Creates an expression that returns the first substring of a string expression that matches a
+ * specified regular expression.
+ *
+ *
This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
+ * syntax.
+ *
+ * @param pattern The regular expression to search for.
+ * @return A new {@link Expression} representing the regular expression find function.
+ */
+ @BetaApi
+ public final Expression regexFind(Object pattern) {
+ return regexFind(this, toExprOrConstant(pattern));
+ }
+
+ /**
+ * Creates an expression that evaluates to a list of all substrings in a string expression that
+ * match a specified regular expression.
+ *
+ *
This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression
+ * syntax.
+ *
+ * @param pattern The regular expression to search for.
+ * @return A new {@link Expression} that evaluates to a list of matched substrings.
+ */
+ @BetaApi
+ public final Expression regexFindAll(Object pattern) {
+ return regexFindAll(this, toExprOrConstant(pattern));
+ }
+
/**
* Creates an expression that checks if this string expression matches a specified regular
* expression.
diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java
index 6fd9075b71..5f810332f1 100644
--- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java
+++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java
@@ -1046,6 +1046,56 @@ public void testRegexContains() throws Exception {
assertThat(data(results)).hasSize(5);
}
+ @Test
+ public void testRegexFind() throws Exception {
+ assumeFalse(
+ "Regexes are not supported against the emulator",
+ isRunningAgainstFirestoreEmulator(firestore));
+
+ List results =
+ firestore
+ .pipeline()
+ .createFrom(collection)
+ .select(field("title").regexFind("^\\w+").as("firstWordInTitle"))
+ .sort(field("firstWordInTitle").ascending())
+ .limit(3)
+ .execute()
+ .get()
+ .getResults();
+
+ assertThat(data(results))
+ .isEqualTo(
+ Lists.newArrayList(
+ map("firstWordInTitle", "1984"),
+ map("firstWordInTitle", "Crime"),
+ map("firstWordInTitle", "Dune")));
+ }
+
+ @Test
+ public void testRegexFindAll() throws Exception {
+ assumeFalse(
+ "Regexes are not supported against the emulator",
+ isRunningAgainstFirestoreEmulator(firestore));
+
+ List results =
+ firestore
+ .pipeline()
+ .createFrom(collection)
+ .select(field("title").regexFindAll("\\w+").as("wordsInTitle"))
+ .sort(field("wordsInTitle").ascending())
+ .limit(3)
+ .execute()
+ .get()
+ .getResults();
+
+ assertThat(data(results))
+ .isEqualTo(
+ Lists.newArrayList(
+ map("wordsInTitle", Lists.newArrayList("1984")),
+ map("wordsInTitle", Lists.newArrayList("Crime", "and", "Punishment")),
+ map("wordsInTitle", Lists.newArrayList("Dune"))));
+ }
+
@Test
public void testRegexMatches() throws Exception {
assumeFalse(
diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java
index 158037e09b..1712046be9 100644
--- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java
+++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java
@@ -1947,9 +1947,8 @@ public void arrayContainsAnyQueries() throws Exception {
if (getFirestoreEdition() == FirestoreEdition.STANDARD) {
assertEquals(asList("a", "b", "d", "e"), querySnapshotToIds(query.get().get()));
} else {
- // TODO: Currently rejected because of mixed type setup, backend will change the behavior; and
- // this test will fail by then.
- assertThrows(ExecutionException.class, () -> querySnapshotToIds(query.get().get()));
+ assertThat(querySnapshotToIds(query.get().get()))
+ .containsExactlyElementsIn(asList("a", "b", "d", "e"));
}
}
diff --git a/grpc-google-cloud-firestore-admin-v1/pom.xml b/grpc-google-cloud-firestore-admin-v1/pom.xml
index 8dc03a4ad9..1604037757 100644
--- a/grpc-google-cloud-firestore-admin-v1/pom.xml
+++ b/grpc-google-cloud-firestore-admin-v1/pom.xml
@@ -4,13 +4,13 @@
4.0.0
com.google.api.grpc
grpc-google-cloud-firestore-admin-v1
- 3.37.0
+ 3.38.0
grpc-google-cloud-firestore-admin-v1
GRPC library for grpc-google-cloud-firestore-admin-v1
com.google.cloud
google-cloud-firestore-parent
- 3.37.0
+ 3.38.0
diff --git a/grpc-google-cloud-firestore-v1/pom.xml b/grpc-google-cloud-firestore-v1/pom.xml
index a385172552..490ddf7a41 100644
--- a/grpc-google-cloud-firestore-v1/pom.xml
+++ b/grpc-google-cloud-firestore-v1/pom.xml
@@ -4,13 +4,13 @@
4.0.0
com.google.api.grpc
grpc-google-cloud-firestore-v1
- 3.37.0
+ 3.38.0
grpc-google-cloud-firestore-v1
GRPC library for grpc-google-cloud-firestore-v1
com.google.cloud
google-cloud-firestore-parent
- 3.37.0
+ 3.38.0
diff --git a/pom.xml b/pom.xml
index 00633e6976..afffaf0ad3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.google.cloud
google-cloud-firestore-parent
pom
- 3.37.0
+ 3.38.0
Google Cloud Firestore Parent
https://github.com/googleapis/java-firestore
@@ -14,7 +14,7 @@
com.google.cloud
sdk-platform-java-config
- 3.56.1
+ 3.57.0
@@ -150,32 +150,32 @@
com.google.api.grpc
proto-google-cloud-firestore-admin-v1
- 3.37.0
+ 3.38.0
com.google.cloud
google-cloud-firestore
- 3.37.0
+ 3.38.0
com.google.cloud
proto-google-cloud-firestore-bundle-v1
- 3.37.0
+ 3.38.0
com.google.api.grpc
proto-google-cloud-firestore-v1
- 3.37.0
+ 3.38.0
com.google.api.grpc
grpc-google-cloud-firestore-admin-v1
- 3.37.0
+ 3.38.0
com.google.api.grpc
grpc-google-cloud-firestore-v1
- 3.37.0
+ 3.38.0
diff --git a/proto-google-cloud-firestore-admin-v1/pom.xml b/proto-google-cloud-firestore-admin-v1/pom.xml
index 22bf5e9607..a0d2ef07f3 100644
--- a/proto-google-cloud-firestore-admin-v1/pom.xml
+++ b/proto-google-cloud-firestore-admin-v1/pom.xml
@@ -4,13 +4,13 @@
4.0.0
com.google.api.grpc
proto-google-cloud-firestore-admin-v1
- 3.37.0
+ 3.38.0
proto-google-cloud-firestore-admin-v1
PROTO library for proto-google-cloud-firestore-admin-v1
com.google.cloud
google-cloud-firestore-parent
- 3.37.0
+ 3.38.0
diff --git a/proto-google-cloud-firestore-bundle-v1/pom.xml b/proto-google-cloud-firestore-bundle-v1/pom.xml
index 9d9e160564..fd731cd4c9 100644
--- a/proto-google-cloud-firestore-bundle-v1/pom.xml
+++ b/proto-google-cloud-firestore-bundle-v1/pom.xml
@@ -5,14 +5,14 @@
4.0.0
proto-google-cloud-firestore-bundle-v1
- 3.37.0
+ 3.38.0
proto-google-cloud-firestore-bundle-v1
PROTO library for proto-google-cloud-firestore-bundle-v1
com.google.cloud
google-cloud-firestore-parent
- 3.37.0
+ 3.38.0
diff --git a/proto-google-cloud-firestore-v1/pom.xml b/proto-google-cloud-firestore-v1/pom.xml
index a11b3e6405..dc1eabd055 100644
--- a/proto-google-cloud-firestore-v1/pom.xml
+++ b/proto-google-cloud-firestore-v1/pom.xml
@@ -4,13 +4,13 @@
4.0.0
com.google.api.grpc
proto-google-cloud-firestore-v1
- 3.37.0
+ 3.38.0
proto-google-cloud-firestore-v1
PROTO library for proto-google-cloud-firestore-v1
com.google.cloud
google-cloud-firestore-parent
- 3.37.0
+ 3.38.0
diff --git a/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java b/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java
index aeb373747c..cf6efe72d1 100644
--- a/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java
+++ b/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java
@@ -1257,6 +1257,32 @@ void regexContainsFunction() throws ExecutionException, InterruptedException {
System.out.println(result.getResults());
}
+ void regexFindFunction() throws ExecutionException, InterruptedException {
+ // [START regex_find]
+ Pipeline.Snapshot result =
+ firestore
+ .pipeline()
+ .collection("documents")
+ .select(regexFind(field("email"), "@[A-Za-z0-9.-]+").as("domain"))
+ .execute()
+ .get();
+ // [END regex_find]
+ System.out.println(result.getResults());
+ }
+
+ void regexFindAllFunction() throws ExecutionException, InterruptedException {
+ // [START regex_find_all]
+ Pipeline.Snapshot result =
+ firestore
+ .pipeline()
+ .collection("documents")
+ .select(regexFindAll(field("comment"), "@[A-Za-z0-9_]+").as("mentions"))
+ .execute()
+ .get();
+ // [END regex_find_all]
+ System.out.println(result.getResults());
+ }
+
void regexMatchFunction() throws ExecutionException, InterruptedException {
// [START regex_match]
Pipeline.Snapshot result =
diff --git a/versions.txt b/versions.txt
index f58a472c6b..db54585cbc 100644
--- a/versions.txt
+++ b/versions.txt
@@ -1,11 +1,11 @@
# Format:
# module:released-version:current-version
-google-cloud-firestore:3.37.0:3.37.0
-google-cloud-firestore-admin:3.37.0:3.37.0
-google-cloud-firestore-bom:3.37.0:3.37.0
-grpc-google-cloud-firestore-admin-v1:3.37.0:3.37.0
-grpc-google-cloud-firestore-v1:3.37.0:3.37.0
-proto-google-cloud-firestore-admin-v1:3.37.0:3.37.0
-proto-google-cloud-firestore-v1:3.37.0:3.37.0
-proto-google-cloud-firestore-bundle-v1:3.37.0:3.37.0
+google-cloud-firestore:3.38.0:3.38.0
+google-cloud-firestore-admin:3.38.0:3.38.0
+google-cloud-firestore-bom:3.38.0:3.38.0
+grpc-google-cloud-firestore-admin-v1:3.38.0:3.38.0
+grpc-google-cloud-firestore-v1:3.38.0:3.38.0
+proto-google-cloud-firestore-admin-v1:3.38.0:3.38.0
+proto-google-cloud-firestore-v1:3.38.0:3.38.0
+proto-google-cloud-firestore-bundle-v1:3.38.0:3.38.0