From 3a9922e2d3510d56131c968ede33e2e3ff7f1989 Mon Sep 17 00:00:00 2001 From: Matthias Schur <107557548+MattSchur@users.noreply.github.com> Date: Thu, 20 Nov 2025 11:10:52 +0100 Subject: [PATCH 1/5] Java: Search in Maps --- java/working-with-cql/query-api.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/java/working-with-cql/query-api.md b/java/working-with-cql/query-api.md index b78376698..f23034b27 100644 --- a/java/working-with-cql/query-api.md +++ b/java/working-with-cql/query-api.md @@ -610,6 +610,26 @@ Select.from("bookshop.Books") .search(term -> term.has("Allen").or(term.has("Heights"))); ``` +#### Search in sub-elements of Map + +You can also search for values of sub-elements of a [cds.Map](cds-data.md#cds-map) element by adding a path to the sub-element to the search scope: + +```cds +entity Book : cuid { + category : String; + details : Map; +} +``` + +```Java +Select.from(BOOK) + .search("CAP Java", List.of("details.summary")) + .where(p -> p.category().eq("Software development")); +``` + +::: warning +Searching by content of a map element can be expensive on large datasets. Use additional filters on non-map elements to reduce the dataset. +::: #### Using `where` Clause {#where-clause} From 40379b7dd87076f88eff662b1671cdbe8da485a9 Mon Sep 17 00:00:00 2001 From: Matthias Schur <107557548+MattSchur@users.noreply.github.com> Date: Thu, 20 Nov 2025 11:21:30 +0100 Subject: [PATCH 2/5] Update java/working-with-cql/query-api.md --- java/working-with-cql/query-api.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/java/working-with-cql/query-api.md b/java/working-with-cql/query-api.md index f23034b27..bc4b94321 100644 --- a/java/working-with-cql/query-api.md +++ b/java/working-with-cql/query-api.md @@ -629,6 +629,8 @@ Select.from(BOOK) ::: warning Searching by content of a map element can be expensive on large datasets. Use additional filters on non-map elements to reduce the dataset. + +Including the entire map element in the search scope triggers a full-text search on its JSON representation, matching both sub-element names and values. This behavior may yield unexpected results. ::: #### Using `where` Clause {#where-clause} From 808167e6c46c55f3805ad0867b18825f64db5736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Jeglinsky?= Date: Wed, 26 Nov 2025 15:20:23 +0100 Subject: [PATCH 3/5] Apply suggestions from code review --- java/working-with-cql/query-api.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/java/working-with-cql/query-api.md b/java/working-with-cql/query-api.md index bc4b94321..654e73ab0 100644 --- a/java/working-with-cql/query-api.md +++ b/java/working-with-cql/query-api.md @@ -610,9 +610,9 @@ Select.from("bookshop.Books") .search(term -> term.has("Allen").or(term.has("Heights"))); ``` -#### Search in sub-elements of Map +#### Search in Sub-Elements of Map -You can also search for values of sub-elements of a [cds.Map](cds-data.md#cds-map) element by adding a path to the sub-element to the search scope: +You can search for values in sub-elements of a [cds.Map](cds-data.md#cds-map) element by adding a path to the sub-element in the search scope: ```cds entity Book : cuid { @@ -628,9 +628,9 @@ Select.from(BOOK) ``` ::: warning -Searching by content of a map element can be expensive on large datasets. Use additional filters on non-map elements to reduce the dataset. +Searching by content of a map element can be expensive on large datasets. Use additional filters on non-map elements to reduce the dataset size. -Including the entire map element in the search scope triggers a full-text search on its JSON representation, matching both sub-element names and values. This behavior may yield unexpected results. +Including the entire map element in the search scope triggers a full-text search on its JSON representation, matching both sub-element names and values. This behavior can yield unexpected results. ::: #### Using `where` Clause {#where-clause} From 3ec3c7454cb414c544e98b506c2fbb121bbd1a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Jeglinsky?= Date: Tue, 2 Dec 2025 12:56:13 +0100 Subject: [PATCH 4/5] Update java/working-with-cql/query-api.md --- java/working-with-cql/query-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/working-with-cql/query-api.md b/java/working-with-cql/query-api.md index 847d741bd..e93f73648 100644 --- a/java/working-with-cql/query-api.md +++ b/java/working-with-cql/query-api.md @@ -669,7 +669,7 @@ Select.from("bookshop.Books") #### Search in Sub-Elements of Map -You can search for values in sub-elements of a [cds.Map](cds-data.md#cds-map) element by adding a path to the sub-element in the search scope: +You can search for values in sub-elements of a [cds.Map](../cds-data#cds-map) element by adding a path to the sub-element in the search scope: ```cds entity Book : cuid { From d441006bd82ac4f4ded121f2a6447d26d7c12dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Jeglinsky?= Date: Tue, 2 Dec 2025 13:00:15 +0100 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: Matthias Schur <107557548+MattSchur@users.noreply.github.com> --- java/working-with-cql/query-api.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java/working-with-cql/query-api.md b/java/working-with-cql/query-api.md index e93f73648..33033b13c 100644 --- a/java/working-with-cql/query-api.md +++ b/java/working-with-cql/query-api.md @@ -678,6 +678,7 @@ entity Book : cuid { } ``` +For example to search for books in the "Software development" category having "CAP Java" within the _summary_ sub-element of the _details_ map: ```Java Select.from(BOOK) .search("CAP Java", List.of("details.summary")) @@ -685,7 +686,7 @@ Select.from(BOOK) ``` ::: warning -Searching by content of a map element can be expensive on large datasets. Use additional filters on non-map elements to reduce the dataset size. +Searching within map element content can be expensive on large datasets. Use additional filters on non-map elements to reduce the dataset size. Including the entire map element in the search scope triggers a full-text search on its JSON representation, matching both sub-element names and values. This behavior can yield unexpected results. :::