-
Notifications
You must be signed in to change notification settings - Fork 133
Searchable @Common.Text Annotation #2041
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@MattSchur does that also hold true for Java?
Co-authored-by: sjvans <[email protected]>
@@ -426,6 +426,23 @@ Searches all elements of type `String` excluding the element `isbn`, which leave | |||
You can explicitly annotate calculated elements to make them searchable, even though they aren't searchable by default. The virtual elements won't be searchable even if they're explicitly annotated. | |||
::: | |||
|
|||
#### The `@Common.Text` Annotation | |||
|
|||
If an entity has an element annotated with the `@Common.Text` annotation, then the property that holds the display text is by default added to the searchable elements. Example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an entity has an element annotated with the `@Common.Text` annotation, then the property that holds the display text is by default added to the searchable elements. Example: | |
The `@Common.Text` annotation allows you to specify a property that holds a text to be displayed on the UI instead of the value of the annotated property. To enhance the user experience, the property that holds the display text is searched by default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MattSchur the subsection The @Common.Text Annotation
belongs to the Searching Data
section, right after @cds.search
. I think @Common.Text
should be described here only from the search perspective, not as UI annotation.
If we need to describe what @Common.Text
means as UI annotation, we can add it here https://cap.cloud.sap/docs/advanced/odata, where it mentioned several times.
Also the exact same text is used in the Java release notes and will be used in the Node release notes as well with the link to this documentation. I think it should be rephrased with the focus on the search.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I didn't notice that this is a subsection of Search
author : Association to Author; | ||
} | ||
``` | ||
The default searchable elements of `Books` are `title` and `author.name`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default searchable elements of `Books` are `title` and `author.name`. | |
Here the value of the name property of the Authors entity is displayed on the UI instead of the author association and is also searched automatically, without requiring additional configuration. |
The default searchable elements of `Books` are `title` and `author.name`. | ||
|
||
::: warning | ||
Do not use both `@cds.search` and `@Common.Text` annotations on the same entity, unless `@cds.search` is used only to exclude fields. If both are present and `@cds.search` includes fields, the `@Common.Text` annotation will be ignored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this specific to @Common.Text
? AFAIK @cds.search
with include fields overrides all default search elements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this specific to
@Common.Text
? AFAIK@cds.search
with include fields overrides all default search elements
@cds.search: { author }
will add all searchable elements of the associated Authors
entity to all searchable elements of the Books
entity, not overwrite them. Mentioning explicitly, that @cds.search
with included fields has a priority over @Common.Text
, allows to avoid confusion in the case both annotations are used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I add @cds.search: { description }
, is title
still searched?
yes: https://pages.github.tools.sap/cap/docs/releases/apr25#enhanced-search |
Co-authored-by: Matthias Schur <[email protected]>
No description provided.