SAP HANA Search Developer Guide Content
Total Page:16
File Type:pdf, Size:1020Kb
PUBLIC SAP HANA Platform 2.0 SPS 01 Document Version: 1.0 – 2017-04-12 SAP HANA Search Developer Guide Content 1 SAP HANA Search Developer Guide..............................................4 2 Defining the Persistency and Indexing............................................6 2.1 Creating Full-Text Indexes Using CDS Annotations..................................... 7 2.2 Creating Full-Text Indexes Using SQL..............................................10 Full-Text Index Types.......................................................11 Synchronization...........................................................15 Text Analysis.............................................................18 Dropping Full-Text Indexes...................................................19 Altering Full-Text Index Parameters.............................................19 Full-Text Index Parameters.................................................. 20 3 Creating Search Models......................................................27 3.1 Transformation Rules for CDS Views.............................................. 27 3.2 Modeling with CDS Annotations (XS Advanced)...................................... 28 Annotation Search.........................................................29 Annotation EnterpriseSearch .................................................34 Annotation EnterpriseSearchHana.............................................42 Annotation Hierarchy.......................................................46 Annotation Semantics......................................................47 CDSTypes.............................................................. 50 Creating a Term Mapping Table via CDS.........................................50 Example: Defining Search Configurations.........................................51 3.3 Modeling with CDS Annotations (XS Classic).........................................55 Annotation Search (XS Classic)............................................... 55 Annotation EnterpriseSearch (XS Classic)........................................57 Example: Defining Search Configurations (XS Classic)...............................60 3.4 Modeling with Built-In Procedure sys.esh_config().....................................61 Interface of sys.esh_config()..................................................61 Creating a Configuration with Method 'POST' .....................................64 Updating or Creating a Configuration with Method 'PUT'..............................66 Deleting a Configuration with Method 'DELETE'....................................66 Privileges...............................................................67 Annotations for sys.esh_config()...............................................67 3.5 Modeling With Attribute Views...................................................81 4 Accessing Data Using Full-Text Search.......................................... 83 4.1 Full-Text Search with OData.................................................... 83 SAP HANA Search Developer Guide 2 PUBLIC Content Custom Query Option 'search'................................................84 Custom Query Option 'facets'.................................................85 Custom Query Option 'facetlimit'.............................................. 85 Custom Query Option 'estimate'...............................................86 Custom Query Option 'wherefound'............................................ 86 OData Features and Limitations...............................................87 4.2 Federated Full-Text Search with Built-In Procedure sys.esh_search().......................88 Interface of sys.esh_search().................................................88 Method 'GET' - $metadata Call................................................90 Supported SQL Types......................................................98 Row Operator............................................................101 Separation of User Input and Other Filter Conditions................................102 Search in a Single View.....................................................103 Federated Search Request over Multiple Views....................................103 Query Options Supported by Federated Search................................... 104 Limit Search to one Schema.................................................105 Response of a Federated Search..............................................105 Privileges Needed to Call sys.esh_search().......................................119 Supported OData System Query Options........................................120 OData Custom Query Options for Search........................................123 OData Custom Functions for Search........................................... 125 Search Query Language....................................................126 Annotations in the Search Response........................................... 131 @com.sap.vocabularies.Search.v1.Ranking.......................................131 Dynamic Search Configurations.............................................. 132 Definition of the User Language...............................................136 Writing the Search Response to a Table.........................................137 4.3 Full-Text Search with SQL.....................................................138 Search Queries with CONTAINS.............................................. 139 EXACT Search...........................................................143 LINGUISTIC Search.......................................................144 FUZZY Search...........................................................149 5 Creating Search UIs With SAPUI5............................................. 296 6 SAP File Processing for SAP HANA.............................................297 7 SAP HANA File Loader......................................................298 SAP HANA Search Developer Guide Content PUBLIC 3 1 SAP HANA Search Developer Guide With the SAP HANA platform, your users can search tables and views much like they would when searching for information on the Internet. In SAP HANA, you can either query data using OData service definitions, directly with SQL queries, or via the built-in procedure sys.esh_search(). You build your UIs using SAPUI5. Prerequisites Before enabling search, note the following prerequisites: ● Your SAP HANA database must contain column-oriented tables. ● A valid data type must be assigned to each column. The data types of the columns determine how you can query your data. Context In SAP HANA, you can search on single or multiple columns of almost any visible data type. In addition to standard string search, SAP HANA also supports full-text search. During a full-text search, the SAP HANA search engine examines both structured text, such as author and date attributes, and unstructured text, such as body text. Unlike a string search, the sequence of words and characters used for a text search is not critical for finding matches. A full-text index enables this functionality by analyzing and preprocessing the available text semantically. This includes normalization, tokenization, word stemming, and part of speech tagging. Procedure To enable search in SAP HANA, proceed as follows: 1. Define the persistency and indexing. 2. Create your search models. 3. Access your data using full-text search. 4. Create your search UI. Related Information Defining the Persistency and Indexing [page 6] SAP HANA Search Developer Guide 4 PUBLIC SAP HANA Search Developer Guide Creating Search Models [page 27] Accessing Data Using Full-Text Search [page 83] Creating Search UIs With SAPUI5 [page 296] SAP HANA Search Developer Guide SAP HANA Search Developer Guide PUBLIC 5 2 Defining the Persistency and Indexing The first task when developing a search application is to define the persistency of your data before you can index the data for a search. Context There are two ways to define database tables, views and indexes, and search-related settings. ● Programming model A You can use Core Data Services (CDS) with its annotations syntax. ● Programming model B You can use the SQL syntax. Note We recommend using programming model A: CDS search annotations. Procedure 1. Define the persistency for your data. Create database tables, which store the data that you want to search for. Create views to model your data. Views are also needed for the OData service definitions in the CDS programming model. 2. Define indexes and choose the columns which you want to search in. Use a powerful set of properties to set up all search related functions you want to use, for example the search mode FUZZY or text analysis. Related Information Creating Full-Text Indexes Using CDS Annotations [page 7] Creating Full-Text Indexes Using SQL [page 10] SAP HANA Search Developer Guide 6 PUBLIC Defining the Persistency and Indexing 2.1 Creating Full-Text Indexes Using CDS Annotations CDS uses a SQL-like syntax to define full-text indexes and fuzzy search indexes in the technical configuration part of an entity definition. Procedure 1. You use the technical configuration part of the entity definition (in an .hdbcds or .hdbdd file) to create full-text indexes and fuzzy search indexes. CDS entities are used to define database tables. The elements of an entity describe the columns of the table. For more information, see SAP HANA Developer Guide For SAP HANA XS Advanced Model and SAP HANA Core Data Services CDS Reference. 2. Add a technical configuration part to the entity definition. 3. Define the full-text index or fuzzy search index