Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions java/working-with-cql/query-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,28 @@ Select.from("bookshop.Books")
.search(term -> term.has("Allen").or(term.has("Heights")));
```

#### Search in Sub-Elements of Map <Beta />

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a brief explanation of what a Map element is or provide a more prominent link to the cds.Map documentation for readers who may not be familiar with this concept.


```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 size.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider rephrasing for better clarity: "Searching within map element content can be expensive on large datasets. Use additional filters on non-map elements to reduce the dataset size before performing map searches."


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}

Expand Down
Loading