You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: advanced/odata.md
+6-3Lines changed: 6 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1111,9 +1111,12 @@ Provide support for hierarchy attribute calculation and navigation, and allow th
1111
1111
1112
1112
- <sup>(1)</sup> Beta feature, API may change
1113
1113
1114
-
::: warning
1115
-
Generic implementation is supported on SAP HANA only
1116
-
:::
1114
+
Generic implementation is supported on the following databases:
1115
+
1116
+
|| SAP HANA | H2 | PostgreSQL | SQLite |
1117
+
|---|---|---|---|---|
1118
+
| CAP Java | ✓ | ✓ |||
1119
+
| CAP Node.js | ✓ ||✓ |✓ |
1117
1120
1118
1121
:::info
1119
1122
The source elements of the entity defining the recursive parent-child relation are identified by a naming convention or aliases `node_id` and `parent_id`.
Copy file name to clipboardExpand all lines: guides/databases-hana.md
+82-50Lines changed: 82 additions & 50 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,9 @@
1
1
---
2
2
status: released
3
-
impl-variants: true
4
3
---
5
4
6
5
# Using SAP HANA Cloud for Production
7
6
8
-
<ImplVariantsHint />
9
-
10
7
[[toc]]
11
8
12
9
@@ -20,52 +17,42 @@ CAP isn't validated with other variants of SAP HANA, like "SAP HANA Database as
20
17
21
18
## Setup & Configuration
22
19
23
-
<divclass="impl node">
24
-
25
-
Run this to use SAP HANA Cloud for production:
20
+
To use SAP HANA Cloud for production, add a dependency to the _package.json_ for Node.js or to the _pom.xml_ for a CAP Java application:
26
21
27
-
```sh
22
+
::: code-group
23
+
```sh [Shell/Bash]
28
24
npm add @cap-js/hana
29
25
```
30
26
31
-
::: details Using other SAP HANA drivers...
32
-
33
-
Package `@cap-js/hana` uses the [`hdb`](https://www.npmjs.com/package/hdb) driver by default. You can override that by running [`npm add @sap/hana-client`](https://www.npmjs.com/package/@sap/hana-client), thereby adding it to your package dependencies, which then takes precedence over the default driver.
34
-
35
-
:::
36
-
37
-
::: tip Prefer `cds add`
38
-
39
-
... as documented in the [deployment guide](deployment/to-cf#_1-sap-hana-database), which also does the equivalent of `npm add @cap-js/hana` but in addition cares for updating `mta.yaml` and other deployment resources.
40
-
41
-
:::
42
-
43
-
</div>
44
-
45
-
<divclass="impl java">
46
-
47
-
To use SAP HANA Cloud, [configure a module](../java/developing-applications/building#standard-modules), which includes the feature `cds-feature-hana`.
48
-
For example, add a Maven runtime dependency to the `cds-feature-hana` feature:
49
-
50
-
```xml
27
+
```xml [pom.xml]
51
28
<dependency>
52
29
<groupId>com.sap.cds</groupId>
53
30
<artifactId>cds-feature-hana</artifactId>
54
31
<scope>runtime</scope>
55
32
</dependency>
56
33
```
34
+
:::
57
35
58
-
::: tip
36
+
::: details Using other SAP HANA drivers...
59
37
60
-
The [modules](../java/developing-applications/building#standard-modules)`cds-starter-cloudfoundry` and `cds-starter-k8s` include `cds-feature-hana`.
38
+
Package `@cap-js/hana` uses the [`hdb`](https://www.npmjs.com/package/hdb) driver by default. You can override that by running [`npm add @sap/hana-client`](https://www.npmjs.com/package/@sap/hana-client), thereby adding it to your package dependencies, which then takes precedence over the default driver.
61
39
62
40
:::
63
41
64
-
The datasource for HANA is then auto-configured based on available service bindings of type *service-manager* and *hana*.
42
+
:::details In CAP Java ...
43
+
The [modules](../java/developing-applications/building#standard-modules)`cds-starter-cloudfoundry` and `cds-starter-k8s` include `cds-feature-hana`.
44
+
45
+
The datasource for SAP HANA is then auto-configured based on available service bindings of type *service-manager* and *hana*.
65
46
66
47
[Learn more about the configuration of an SAP HANA Cloud Database](../java/cqn-services/persistence-services#sap-hana){ .learn-more}
48
+
:::
49
+
50
+
::: tip Prefer `cds add`
51
+
52
+
... as documented in the [deployment guide](deployment/to-cf#_1-sap-hana-database), which also does the equivalent of `npm add @cap-js/hana` but in addition cares for updating `mta.yaml` and other deployment resources.
53
+
54
+
:::
67
55
68
-
</div>
69
56
70
57
71
58
@@ -266,41 +253,86 @@ The HANA Service provides dedicated support for native SAP HANA features as foll
266
253
267
254
### Vector Embeddings { #vector-embeddings }
268
255
269
-
Vector embeddings are numerical representations that capture important features and semantics of unstructured data - such as text, images, or audio. This representation makes vector embeddings of similar data have high similarity and low distance to each other. These properties of vector embeddings facilitate tasks like similarity search, anomaly detection, recommendations and Retrieval Augmented Generation (RAG). Vector embeddings from a vector datastore such as the [SAP HANA Cloud Vector Engine](https://community.sap.com/t5/technology-blogs-by-sap/sap-hana-cloud-s-vector-engine-announcement/ba-p/13577010) can help get better generative AI (GenAI) results. This is achieved when the embeddings are used as context to the large language models (LLMs) prompts.
256
+
Vector embeddings let you add semantic search, recommendations, and generative AI features to your CAP application. Embeddings are numeric arrays that represent the meaning of unstructured data (text, images, etc.), making it possible to compare and search for items that are semantically related to each other or a user query.
270
257
271
-
Typically vector embeddings are computed using an **embedding model**. The embedding model is specifically designed to capture important features and semantics of a specific type of data, it also determines the dimensionality of the vector embedding space. Unified consumption of embedding models and LLMs across different vendors and open source models is provided via the [SAP Generative AI Hub](https://community.sap.com/t5/technology-blogs-by-sap/how-sap-s-generative-ai-hub-facilitates-embedded-trustworthy-and-reliable/ba-p/13596153).
258
+
#### Choose an Embedding Model
272
259
273
-
In CAP, vector embeddings are stored in elements of type [cds.Vector](../cds/types):
260
+
Choose an embedding model that fits your use case and data (for example english or multilingual text). The model determines the number of dimensions of the resulting output vector. Check the documentation of the respective embedding model for details.
Use the [SAP Generative AI Hub](https://community.sap.com/t5/technology-blogs-by-sap/how-sap-s-generative-ai-hub-facilitates-embedded-trustworthy-and-reliable/ba-p/13596153) for unified consumption of embedding models and LLMs across different vendors and open source models. Check for available models on the [SAP AI Launchpad](https://help.sap.com/docs/ai-launchpad/sap-ai-launchpad-user-guide/models-and-scenarios-in-generative-ai-hub-fef463b24bff4f44a33e98bb1e4f3148#models).
263
+
264
+
#### Add Embeddings to Your CDS Model
265
+
Use the `cds.Vector` type in your CDS model to store embeddings on SAP HANA Cloud. Set the dimension to match your embedding model (for example, 1536 embedding dimensions for OpenAI *text-embedding-3-small*).
266
+
267
+
```cds
268
+
entity Books : cuid {
269
+
title : String(111);
270
+
description : LargeString;
271
+
embedding : Vector(1536); // adjust dimensions to embedding model
272
+
}
273
+
```
274
+
275
+
#### Generate Embeddings
276
+
Use an embedding model to convert your data (for example, book descriptions) into vectors. The [SAP Cloud SDK for AI](https://sap.github.io/ai-sdk/) makes it easy to call SAP AI Core services to generate these embeddings.
277
+
278
+
:::details Example using SAP Cloud SDK for AI
279
+
```Java
280
+
var aiClient =OpenAiClient.forModel(OpenAiModel.TEXT_EMBEDDING_3_SMALL);
At runtime, you can compute the similarity and distance of vectors in the SAP HANA vector store using the `cosineSimilarity` and `l2Distance` (Euclidean distance) functions in queries:
287
+
#### Query for Similarity
288
+
At runtime, use SAP HANA's built-in vector functions to search for similar items. For example, find books with embeddings similar to a user question:
284
289
285
290
::: code-group
286
-
```js [Node.js]
287
-
let embedding; // vector embedding as string '[0.3,0.7,0.1,...]';
291
+
```Java [Java]
292
+
// Compute embedding for user question
293
+
var request =newOpenAiEmbeddingRequest(List.of("How to use vector embeddings in CAP?"));
Store embeddings when you create or update your data. Regenerate embeddings if you change your embedding model.
300
321
:::
301
322
323
+
:::tip SAP Cloud SDK for AI
324
+
Use the [SAP Cloud SDK for AI](https://sap.github.io/ai-sdk/) for unified access to embedding models and large language models (LLMs) from [SAP AI Core](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/what-is-sap-ai-core).
325
+
:::
326
+
327
+
328
+
[Learn more about the SAP Cloud SDK for AI (Java)](https://sap.github.io/ai-sdk/docs/java/getting-started) {.learn-more}
329
+
302
330
[Learn more about Vector Embeddings in CAP Java](../java/cds-data#vector-embeddings) {.learn-more}
303
331
332
+
[Learn more about the SAP Cloud SDK for AI (JavaScript)](https://sap.github.io/ai-sdk/docs/js/getting-started) {.learn-more}
> Note: You always need to add the `()` for functions, even if no arguments are required. The OData standard specifies that bound actions/functions need to be prefixed with the service's name. In the previous example, entity `Foo` has a bound action `order`. That action must be called via `/Foo(2)/Sue.order` instead of simply `/Foo(2)/order`.
@@ -1123,18 +1123,45 @@ POST .../sue/Foo(2)/Sue.order {"x":1} // bound action
1123
1123
<br>
1124
1124
1125
1125
1126
-
**Programmatic** usage via **generic APIs** would look like this for Node.js:
1126
+
**Programmatic** usage via **generic APIs** for Node.js:
Copy file name to clipboardExpand all lines: guides/security/authorization.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -190,7 +190,7 @@ service SomeService {
190
190
191
191
#### Events to Auto-Exposed Entities { #events-and-auto-expose}
192
192
193
-
In general, entities can be exposed in services in different ways: it can be **explicitly exposed** by the modeler (for example, by a projection), or it can be **auto-exposed** by the CDS compiler due to some reason.
193
+
In general, entities can be exposed in services in different ways: they can be **explicitly exposed** by the modeler (for example, by a projection), or they can be **auto-exposed** by the CDS compiler due to some reason.
194
194
Access to auto-exposed entities needs to be controlled in a specific way. Consider the following example:
0 commit comments