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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

freestyler to the additional hidden TEXT column. In this case, the mode textsearch=compare and all fuzzy search<br />

options are allowed:<br />

CREATE COLUMN TABLE mytable<br />

(<br />

col1 SHORTTEXT(200)<br />

);<br />

SELECT score() AS score, * FROM mytable WHERE contains(col1, 'a b',<br />

fuzzy(0.8, 'textsearch=compare'));<br />

Fuzzy Search on a FULLTEXT INDEX<br />

When a full text index is created on a column that is not of type TEXT (e.g. NVARCHAR, NCLOB, ...) a hidden text<br />

column is added to the table. A call to contains that references the non-TEXT column is automatically redirected<br />

by the freestyler to the additional text column. In this case, the mode textsearch=compare and all fuzzy search<br />

options are allowed:<br />

CREATE COLUMN TABLE mytable<br />

(<br />

col1 NVARCHAR(2000)<br />

);<br />

CREATE FULLTEXT INDEX myindex ON mytable(col1);<br />

SELECT score() AS score, * FROM mytable WHERE contains(col1, 'a b',<br />

fuzzy(0.8, 'textsearch=compare'));<br />

Merge Delta for Better Performance<br />

When inserting or loading a large number of rows in a table that has a TEXT or SHORTTEXT column or that uses a<br />

FULLTEXT INDEX, it is important to merge the delta part of the table to get a good search performance.<br />

A delta merge can be started manually with the following SQL statement:<br />

MERGE DELTA OF mytable;<br />

Alternatively, a delta merge can be triggered automatically by the mergedog process.<br />

Fuzzy Multi-Token Search on Text Columns<br />

Content Types<br />

When using more than one token within a query, the default content type is AND (for example, ... WHERE<br />

CONTAINS (mycolumn, 'software firm', FUZZY(0.5)) ... will return entries that contain a token similar to 'software'<br />

and a token similar to 'firm').<br />

Alternatively, you can use OR by adding the key word between the tokens (for example, ... WHERE CONTAINS<br />

(mycolumn, 'apple OR 'banana', FUZZY(0.5)) ... will return entries that contain a token similar to 'apple' and<br />

entries that contain a token similar to 'banana').<br />

282<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!