You are on page 1of 31

openSAP

TEXT ANALYTICS WITH SAP HANA
PLATFORM – WEEK 1
Version: January 18, 2016

Exercises / Solutions
Anthony Waite / SAP Labs, LLC.
Bill Miller / SAP Labs, LLC.

Contents
Desktop in SAP Cloud Appliance Library ..................................................................................................... 4
Preconfigured front-end client ........................................................................................................................... 4
Front-End Client Configuration ...................................................................................................................... 6
Getting Help ....................................................................................................................................................... 6
Adding a HANA Studio Perspective .................................................................................................................. 6
Create a Repository Workspace ...................................................................................................................... 11
Create a HANA Project .................................................................................................................................... 13
Important HANA Studio customizations .......................................................................................................... 15
(Mandatory) Set permissions for course exercises ......................................................................................... 17
Exercise 1 – Solution..................................................................................................................................... 20
In SAP HANA Studio ....................................................................................................................................... 20
Exercise 2 – Solution..................................................................................................................................... 24
In SAP HANA Studio ....................................................................................................................................... 24
Exercise 3 – Solution..................................................................................................................................... 27
In SAP HANA Studio ....................................................................................................................................... 27
Exercise 4 – Solution..................................................................................................................................... 29
In SAP HANA Studio ....................................................................................................................................... 29

2

BEFORE YOU START
System Host: HANA IP address
System Instance Number: 00
System User ID: SYSTEM
Password: Master Password you entered for the solution when creating
the instance in the SAP Cloud Appliance Library

3

Note: If you have SAP HANA Studio installed on your computer. bypass this section and jump to the following Adding a HANA Studio Perspective. you can use it instead of the preconfigured front-end client in CAL.DESKTOP IN SAP CLOUD APPLIANCE LIBRARY Preconfigured front-end client Steps Screenshot 1) Click on the “SAP Dev Tools for Eclipse” icon on your desktop in the SAP Cloud Appliance Library (CAL) to open the front-end client. 4 . 2) Click on the “Systems” view. Right-click on “HDB (SYSTEM)”. 3) Select “Log On” from the pop-up menu. If so.

5) You are now logged on to your SAP HANA database. 5 .4) Log on as: User Name: SYSTEM Password: Master Password you specified when creating the instance in SAP CAL Click the “OK” button to close the dialog box.

In the upper right corner of your front-end client.pdf Adding a HANA Studio Perspective Steps Screenshot 1) To support the developercentric workflow. This may not displayed by default. there is an additional Eclipse perspective which has been added to SAP HANA Studio. 3) After adding the “SAP HANA Development” perspective. click the “Open Perspective” button. If that is the case.sap.com/hana/SAP_HANA_Developer_Guide_en. This is the perspective you should be using for the entire workshop. 2) Add the “SAP HANA Development” perspective. you may want to right-click and choose “Close” as we will not be using this or any 6 . you may also still see other perspectives such as “SAP HANA Administration Console”.FRONT-END CLIENT CONFIGURATION Getting Help If you need additional help resources beyond this document: http://help.

other perspectives. 7 .

Create a connection to the HANA server Steps Screenshot 1) Make sure you are in the “SAP HANA Development” perspective by clicking on the button. For those of you using the SAP Dev Tools for Eclipse in CAL. 2) Click on the “Systems” view. bypass this section and jump to the following Create a Repository Workspace. 8 . Right-click on the white space below this tab and choose “Add System…”. Note: This section only applies to you if you are using your own SAP HANA Studio installation on your computer.

Click the “Finish” button.3) Enter the server Host Name: HANA IP address Enter the Instance Number: 00 Optionally. you can enter a meaningful description of your choice. 4) Specify the user ID and password. Click the “Next” button. User Name: SYSTEM Password: Master Password specified when creating the instance in SAP CAL Select the “Store user name and password in secure storage” option. 9 .

Please make sure to use this connection for the rest of the course exercises.5) You should now have a new connection with your specific user ID for the HANA system. Note: The System ID and users shown in these screenshots might be different than the ones you are working with and may be blurred to avoid any confusion. 10 .

Click the “Finish” button. Find your system entry and the default workspace. 2) Confirm the file system location on your local machine which will hold the local copy of this workspace.Create a Repository Workspace Steps Screenshot 1) Switch to the “Repositories” view. Note: In this and the following screenshot. 11 . Right-click and choose “Create Repository Workspace”. your system naming conventions and workspace paths may be different.

For this reason we may have blurred this information in screenshots to avoid confusion. Host Name. Note: Your System ID. 12 .3) You should now see the local workspace mapped to the remote workspace in the “Repositories” view. and System Numbers will be different than those displayed in subsequent screenshots. User ID.

2) Click the “Next” button.Create a HANA Project Steps Screenshot 1) Under the “Repositories” tab. Right-click “student00” and choose “Check Out and Import Projects …” from the popup menu. 13 . Note: It may take several minutes to download the package contents to your local machine. navigate to “(Default) / student00”.

3) Click the “Finish” button to complete the process. You should see the “student00” project that you created in the previous step. 14 . 4) Switch to the “Project Explorer” view.

2) In the “Preferences” dialog box. 15 .Important HANA Studio customizations Steps Screenshot 1) Open “Preferences” from the “Window” menu. select the “Enable zoom of LOB columns” option. under “SAP HANA / Runtime / Result”. Click the “Apply” button.

3) Continuing in the “Preferences” dialog box.hdbtextconfig *. navigate to “General / Editors / File Associations”. highlight “*.sql”. then click the “Default” button. navigate to “General / Appearance / Content Types”. 16 . Click the “Add…” button and enter: *. Note: This particular setting may apply to you if you are using the SAP Dev Tools for Eclipse in CAL.hdbtextdict You will see these two new content types under “File associations”. Under “Associated editors”. Click the “OK” button to close the “Preferences” dialog box. Under the “Content Types” tree. 4) Continuing in the “Preferences” dialog box. navigate to “Text / XML”. highlight “SAP HANA SQL Console”. Under “File types”.

2) If there is “No connection to database” displayed in the SQL console. 17 . Doubleclick on “prepare. navigate to “(Default) / student00 / data”.(Mandatory) Set permissions for course exercises Steps Screenshot 1) Under the “Repositories” view. which is found right of the green circle with an arrow (Execute) icon. click on the “Choose Connection” icon.sql”.

you will notice the following SQL syntax from the “prepare. Note: Disregard this warning message throughout the course exercises. 5) Select the “Don’t show this message again during this editor session” option and click the “Yes” button.sql” file: call "_SYS_REPO". 18 .'SYSTEM' )."GRANT_ACTIVAT ED_ROLE"('student00. 4) In the SQL console.securi ty::TA_DEVELOPER'. Click the “OK” button. Click on the “Execute” (green circle with an arrow) icon or hit the F8 key. select the appropriate database.3) In the “Choose Connection” dialog.

EXERCISE 1 – CREATE FULLTEXT INDEX WITHOUT SPECIFYING LANGUAGES Objective In this exercise. you will execute a SQL statement to create a fulltext index for your copy of the workshop data. we will omit the LANGUAGE DETECTION parameter. Intentionally. Exercise Description  Create fulltext index without specifying possible languages  Search for restaurant terms in the content  Observe that English is assumed for all inputs 19 .

2) If there is “No connection to database” displayed in the SQL console. Double-click on “exercises. click on the “Choose Connection” icon.EXERCISE 1 – SOLUTION In SAP HANA Studio Steps Screenshot 1) Under the “Repositories” tab. 20 . navigate to “(Default) / student00 / solutions / week-1”.sql”. which is found right of the green circle with an arrow (Execute) icon.

data::PRODUCT_R EVIEWS"(CONTENT) FAST PREPROCESS OFF. 3) In the SQL console. highlight the following SQL syntax: SET SCHEMA OPENSAP_TA_WORKSHOP. you will need to re-execute this command at the start. Click on the “Execute” (green circle with an arrow) icon or hit the F8 key. Click the “OK” button. Note: If you close this session at any point while working on Week 1 exercises.2) In the “Choose Connection” dialog. highlight the following SQL syntax: CREATE FULLTEXT INDEX PRODUCT_REVIEWS_IDX ON "student00. 4) In the SQL console. 21 . select the appropriate database.

data::PRODUCT_R EVIEWS" WHERE CONTAINS(CONTENT.Click on the “Execute” (green circle with an arrow) icon or hit the F8 key. LINGUISTIC). 6) As you can see. en = English 22 . these are the results of the search for some restaurant terms in the fulltext content. highlight the following SQL syntax: SELECT FILE_NAME. Notice in the query results that English is assumed for all inputs. LANGUAGE(CONTENT). 'meal OR menu OR entree OR appetizer OR food'. SNIPPETS(CONTENT) FROM "student00. 5) In the SQL console. Click on the “Execute” (green circle with an arrow) icon or hit the F8 key.

Exercise Description  Drop fulltext index from previous exercise  Create fulltext index specifying possible languages  Search for restaurant terms in the content  Language will be automatically determined for all inputs 23 . you will execute a SQL statement to create a fulltext index for your copy of the workshop data.EXERCISE 2 – RECREATE FULLTEXT INDEX SPECIFYING LANGUAGES Objective In this exercise. We will specify the LANGUAGE DETECTION parameter.

data::PRODUCT_R EVIEWS"(CONTENT) FAST PREPROCESS OFF LANGUAGE DETECTION ('EN'. Notice 24 . 'meal OR menu OR entree OR appetizer OR food'. highlight the following SQL syntax: CREATE FULLTEXT INDEX PRODUCT_REVIEWS_IDX ON "student00. Click on the “Execute” (green circle with an arrow) icon or hit the F8 key. 2) In the SQL console. 3) In the SQL console. highlight the following SQL syntax: DROP FULLTEXT INDEX PRODUCT_REVIEWS_IDX. highlight the following SQL syntax: SELECT FILE_NAME. 'FR'). Repeating the same search in EXERCISE 1. 'DE'. click on the “Execute” (green circle with an arrow) icon or hit the F8 key. LANGUAGE(CONTENT). these are the results of the search for some restaurant terms in the fulltext content.data::PRODUCT_R EVIEWS" WHERE CONTAINS(CONTENT. Click on the “Execute” (green circle with an arrow) icon or hit the F8 key.EXERCISE 2 – SOLUTION In SAP HANA Studio Steps Screenshot 1) In the SQL console. LINGUISTIC). 4) As you can see. SNIPPETS(CONTENT) FROM "student00.

in the query results that the correct language is detected for all inputs. en = English de = German fr = French 25 .

EXERCISE 3 – RECREATE FULLTEXT INDEX SPECIFYING LANGUAGES WITH TEXT ANALYSIS ON Objective In this exercise. you will execute a SQL statement to create a fulltext index for your copy of the workshop data. We will specify the LANGUAGE DETECTION and TEXT ANALYSIS ON parameters. Exercise Description  Drop fulltext index from previous exercise  Create fulltext index specifying languages and text analysis output  Notice new table with text analysis annotations for each input 26 .

TA_COUNTER.data::PRODUCT_R EVIEWS"(CONTENT) FAST PREPROCESS OFF LANGUAGE DETECTION ('EN'. Click on the “Execute” (green circle with an arrow) icon or hit the F8 key. Click on the “Execute” (green circle with an arrow) icon or hit the F8 key. 'DE'. highlight the following SQL syntax: SELECT * FROM "$TA_PRODUCT_REVIEWS_IDX" WHERE TA_LANGUAGE = 'en' ORDER BY ID.EXERCISE 3 – SOLUTION In SAP HANA Studio Steps Screenshot 1) In the SQL console. highlight the following SQL syntax: CREATE FULLTEXT INDEX PRODUCT_REVIEWS_IDX ON "student00. 3) In the SQL console. highlight the following SQL syntax: DROP FULLTEXT INDEX PRODUCT_REVIEWS_IDX. Click on the “Execute” (green circle with an arrow) icon or hit the F8 key. 27 . 2) In the SQL console. 'FR') TEXT ANALYSIS ON.

Exercise Description  Run a command to monitor the progress for text processing  Run a command to report any errors for text processing 28 .EXERCISE 4 – MONITOR TEXT ANALYSIS PROCESSING Objective In this exercise. you will learn how to monitor the progress and status of your text data processing.

INDEXING_STATUS(CONTENT). highlight the following SQL syntax: SELECT ID. INDEXING_ERROR_CODE(CONTEN T). Click on the “Execute” (green circle with an arrow) icon or hit the F8 key.M_FULLTEXT_QUEUES WHERE SCHEMA_NAME = 'OPENSAP_TA_WORKSHOP' AND TABLE_NAME = 'student00.a. 3) In the SQL console. Note: This command will be useful later when we start modifying the configuration settings for text analysis.k. Click on the “Execute” (green circle with an arrow) icon or hit the F8 key.data::PRODUCT_R EVIEWS" ORDER BY ID. row of the input table). 29 . 4) Notice this shows the errors for each “job” (document a. highlight the following SQL syntax: SELECT * FROM SYS.data::PRODUCT_R EVIEWS'. 2) Notice the queue status is shown at the table level. INDEXING_ERROR_MESSAGE(CON TENT) FROM "student00.EXERCISE 4 – SOLUTION In SAP HANA Studio Steps Screenshot 1) In the SQL console.

30 .

This document.com © 2015 SAP SE or an SAP affiliate company. . if any. promise. or any related presentation. and SAP SE’s or its affiliated companies’ strategy and possible future developments. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an SAP affiliate company. or functionality. which speak only as of their dates. and SAP SE or its affiliated companies shall not be liable for errors or omissions with respect to the materials. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. or to develop or release any functionality mentioned therein. code. products. Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.epx#trademark for additional trademark information and notices. National product specifications may vary. These materials are provided by SAP SE or an SAP affiliate company for informational purposes only.com/corporate-en/legal/copyright/index. or legal obligation to deliver any material. and they should not be relied upon in making purchasing decisions. Please see http://www. without representation or warranty of any kind. The only warranties for SAP SE or SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and services. The information in this document is not a commitment. Nothing herein should be construed as constituting an additional warranty. In particular. Readers are cautioned not to place undue reliance on these forward-looking statements. SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries.www. and/or platform directions and functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason without notice. SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation.sap. All rights reserved.sap.