CDS Annotations

CDS: Search Annotations – Search.ranking

Annotations enrich the CDS views but can be confusing as well. These series of blogs have my simplified explanation.

Search.ranking annotation is used at the column level and it is used in addition to Search.searchable and Search.defaultSearchElement to further define the search behavior in Fiori Element apps. The possible values are HIGH, MEDIUM and LOW.

Syntax:

@Search.ranking : #HIGH
Or
@Search.ranking : #MEDIUM
Or
@Search.ranking : #LOW

Explanation: As you may already know (if now, follow the links above) that Search.defaultSearchElement can be applied to multiple columns. Search.ranking can then be used to define the relevancy of the columns. High means (obviously) that column is more relevant for search than the other columns and likewise.

Example: (Loaning the example from Search.defaultSearchElement)


@Search.searchable : true
....
define view ZCDS_EXAMPLE .....
.....

@Search.defaultSearchElement : true
@Search.ranking: #HIGH
key field1,

@Search.defaultSearchElement : true
@Search.randking: #LOW
field2,

field3,
......

This means, the when a string in entered in the search generic search field, then field1 matches will have higher relevancy and may appear higher if only a portion of the result set is visible.

You must be wondering why relevancy is important if the search will find values matching both the columns, then for this you need to know another annotation which is impacted by the relevancy. Drum rolls for Search.fuzzinessThreshold. This is the tip for the day and follow the link to know more.

Leave a Reply

Your email address will not be published. Required fields are marked *

error

Enjoy this blog? Please spread the word :)

Follow by Email
Twitter
LinkedIn
LinkedIn
Share