Skip to Content

OData(v2) search option to dynamically search on columns

In native HANA 1.0 (SP12) SQL you have the option when searching on CDS enabled views to limit your search criteria to specific columns only.

For example we have a HANA CDS view with 4 enabled search columns (Description_1 - Description_4)
To restrict the search only to column 1 we can use the following statement in SQL:

SELECT * <viewname> where CONTAINS("Description_1",'waterleakage');

Question is if this is also possible when exposing the CDS view with OData(v2).
So far I haven't been able to find a solution how to do this based on documentation from SAP or OData


I understand that the search criteria is send to the CONTAINS predicate, but the question is if you can also add some additional parameters to this on which columns to search on ?
This without creating separate CDS views/services.

In this case we want for example only to search on Description_1

Many thanks

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Feb 12 at 06:50 PM

    Hi Patrick,

    you have first to enable search on view level by using the annotation.

    @Search.searchable : true;

    as described in this blog:

    In a second step you define which columns of your CDS are to be considered in a freestyle search (for example a SELECT…) where no columns are specified.

    Interestingly the same annotations also work for ABAP based CDS views as described in the SAP Online Documentation (section Search annotations). So if you annotate a CDS based OData Service in S/4HANA or Suite on HANA it would work as well.

    That means you don't have to bother with complicated $filter statements nor have your OData Clients to specifiy which columns to search.

    Best Regards,


    Add comment
    10|10000 characters needed characters exceeded

  • Feb 12 at 02:12 PM

    hi Patrick,

    rather than just telling you how to do a like operation in odata v2... here is the url to the documentation for the various operation queries you can perform on Odata:

    keep in mind you can use multiple operators on various columns using an & to join several operations

    hope this helps you.

    Add comment
    10|10000 characters needed characters exceeded