28.01.2013 Views

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

First, open the context menu of the Search Rule Set node and select New Stopwords (table-based) or New<br />

Term Mappings (table based).<br />

In the properties of the new nodes, you can define the stopword table and term mapping table that is used.<br />

On the Stopwords (table-based) or Term Mappings (table-based) node, select New Column to enable the<br />

stopwords or term mappings on a column. In the properties panel, you can define the name of the column<br />

where stopwords and term mappings shall be applied.<br />

Below the Column nodes, create new List ID nodes (open the context menu and select New List ID). In each<br />

list ID node, you can configure a stopword or term mapping list that is applied on the column.<br />

The stopword and term mapping settings are valid for a given column in all rules.<br />

Executing a Search With a Rule Set<br />

<strong>HANA</strong> exports a new built-in function: SYS.EXECUTE_SEARCH_RULE_SET, with which you can execute a<br />

previously defined search rule set.<br />

The function has one parameter, which is an XML string to run the search. Within this XML, you have to specify:<br />

● The ruleset that should be executed<br />

● The way the result will be returned<br />

● The limitation of the result<br />

● The input values<br />

The EXECUTE_SEARCH_RULE_SET method returns by default a ResultSet object. This object contains all the<br />

columns from the referenced attribute view plus additional columns _SCORE and _RULE_ID. Alternatively, the<br />

EXECUTE_SEARCH_RULE_SET can write the result into a results table that needs to be created by the user.<br />

For code samples of SYS.EXECUTE_SEARCH_RULE_SET calls, see Search with a Rule Set - Code Samples [page<br />

304].<br />

Transaction Isolation Level<br />

The EXECUTE_SEARCH_RULE_SET function creates one SELECT statement for each of the rules and runs the<br />

statements independent of each other. The statements are executed in the transaction context of the calling<br />

application and use the same isolation level as the application. The isolation level has an influence on the results of<br />

the EXECUTE_SEARCH_RULE_SET function when there are other transactions running in parallel that change the<br />

contents of the database tables.<br />

When the isolation level 'READ COMMITTED' is used, each of the SELECT statements of the search rule set sees<br />

all changes that have been committed at the time the execution of the SELECT statement begins. So, for example,<br />

the second rule of a rule set may see a new record that was not committed when the first rule has been executed.<br />

In this case, the new record may be returned by the 'wrong' rule and the user gets an incorrect result.<br />

When the isolation levels 'REPEATABLE READ' or 'SERIALIZABLE' are used, all SELECT statements see the same<br />

state of the database. So the results returned by EXECUTE_SEARCH_RULE_SET are always correct.<br />

Search with a Rule Set - Code Samples<br />

Executing a search and returning the result as a ResultSet:<br />

CALL SYS.EXECUTE_SEARCH_RULE_SET('<br />

<br />

<br />

-- specifies the SearchRuleSet<br />

Herbert -- specifies the input value<br />

for column FIRSTNAME<br />

304<br />

P U B L I C<br />

© 2012 <strong>SAP</strong> AG. All rights reserved.<br />

<strong>SAP</strong> <strong>HANA</strong> <strong>Developer</strong> <strong>Guide</strong><br />

Enabling Search

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!