(DI-1802) SAP HANA XS application API
File indexing service API
File indexing service is implemented using 2 services:
- XSODATA service
- Used for full-text search in files
- Also possible to create files and rows, but for more convenient API xsjs service is more suitable
- XS javascript (XSJS) service
- Used for creating files, appending rows, etc.
Service authorizations
Indexing agent application should use database user with assigned role 'dvd.filesearch.roles::agent'.
Technical information
Paramter | Value |
---|---|
Application namespace | dvd.filesearch.FileIndex |
Service path to oData service | /dvd/filesearch/FileIndex.xsodata |
Implementation of File indexing agent
Analyzed file should be parsed by file index agent in way where one row contains information (string) about one event from analyzed file. File agent should be able to identify time of particular event and get information for this event.
In example: We have following file content:
2017-08-16 16:21:21 System is overloaded 2017-08-16 16:21:56 System is OK again
File indexing agent should be able parse file into 2 rows where first row will be parsed into:
- timestamp: 20170816162156
- content: 2017-08-16 16:21:21 System is overloaded
Workflow for implementation File Indexing agent is following:
- Create File origin (id of location where file original resides) using OData entity FileOrigin
dvd.filesearch::FileIndex.FileOrigin
Origin header table where all origin definition are stored.
Field Key Type Description id X NVARCHAR 32 Unique identifier of file origin (i.e. system name where files are coming from) name NVARCHAR 128 Name of origin host NVARCHAR 128 Server host - Create File (full path of file location) using OData entity File
dvd.filesearch::FileIndex.File
File header table where all file definitions are stored.
Field Key Type Description id X INTEGER Unique identifier of file automatically assigned during entry creation guid NVARCHAR 32 Unique identifier of file given by File Indexing agent application name NVARCHAR 255 Full name of file (including full path in origin) origin.id 32 File origin fileType 100 Type of file Create File content using XSJS script /dvd/filesearch/addFileRows.xsjs
dvd.filesearch::FileIndex.FileData
Data that represent content of defined files.
Field Key Type Description fileId X INTEGER Unique identifier of file rowNum X INTEGER Row number of record timestamp TIMESTAMP Time stamp of record content CLOB String content of record
XSODATA service
CDS are exposed to oData entities using XSODATA definition file. OData are mainly used by SAPUI5 application and File indexing agent.
Table | oData entity | Path |
---|---|---|
dvd.filesearch::FileIndex.FileOrigin | FileOrigin | /dvd/filesearch/FileIndex.xsodata/FileOrigin |
dvd.filesearch::FileIndex.File | File | /dvd/filesearch/FileIndex.xsodata/File |
dvd.filesearch::FileIndex.FileData | FileData | /dvd/filesearch/FileIndex.xsodata/FileData |
dvd.filesearch::FileIndex.FileView | FileView | /dvd/filesearch/FileIndex.xsodata/FileView |
More information about properties can be found from metadata of service:
/dvd/filesearch/FileIndex.xsodata/$metadata/
XSJS service
All request should contain following headers and cookies gathered during initial fetch of X-CSRF-Token token.
Header | Value |
---|---|
X-CSRF-Token | <Fetched token> |
Accept | application/json |
Content-Type | application/json |
addFileRows.xsjs
Script path
/dvd/filesearch/addFileRows.xsjs
Request
HTTP method: POST
Request body content example:
{ "guid": "CB1D315DD10C334792A32702B834DAF6", "rows": [ {"timestamp":"20170321103106","content":"2017-03-21 10:31:06 Show me the way to the next whisky bar"}, {"timestamp":"20170321103106","content":"2017-03-21 10:31:06 and don't ask why, and don't ask why"}, {"timestamp":"20170321103106","content":"2017-03-21 10:31:06 What if we don't find the next whisky bar?"}, {"timestamp":"20170321103106","content":"2017-03-21 10:31:06 I'll tell you we must die, I'll tell you we must die!"} ] }
Response
Data are successfully added when response contains HTTP code 2* and response body should look as follows:
{"result":"OK"}
deleteFileRows.xsjs
Script path
/dvd/filesearch/deleteFileRows.xsjs
Request
HTTP method: POST
Request body content example:
{ "guid": "CB1D315DD10C334792A32702B834DAF6" }
Where guid is identificator of file in which content should be deleted.
Response
Data are successfully deleted when response contains HTTP code 2* and response body should look as follows:
{"result":"OK"}