Show TOC

Search and Open Search CapabilitiesLocate this document in the navigation structure

On application UIs there is often a search box where users can enter a free text search string. How this kind of search string is used to find adequate results has to be handled by the application. The custom query option search is intended exactly for passing such a free-text search term to the backend and let the backend decide against which properties of each entity in the entity set the term is matched, and in what way. It may also be matched against properties of related entities.

Sample Code Example of finding all orders with items that refer to a blue product:
GET ~/Orders?search=blue

End of the example.

SAP Gateway offers OpenSearch capabilities for your service implementation. The search term is in parameter IV_SEARCH_STRING of method GET_ENTITYSET of interface /IWBEP/IF_MGW_APPL_SRV_RUNTIME.

The annotation sap:searchable=”true” can be added to an entity set. With this annotation the framework tells the client that it can use the custom query option search.

Note

Note that search works just like $filter: it will return a subset of the entities that are returned when no search term is specified. And it combines with $filter in that only entities that fulfill both conditions are returned.

OpenSearch can be used to tell an OpenSearch client how it can construct URLs with search.

Constraints

If an entity set in Service Builder has been create based on a search help there is at present no code generated that supports search. This has to be done manually by the developer.

Examples
Sample Code OpenSearch description sample:

/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/TravelagencyCollection/OpenSearchDescription.xml
Sample Code Sample search request:

/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/TravelagencyCollection?search=Germany