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.

● stopwordTable=[.]<br />

SELECT TO_DECIMAL(SCORE(),3,2) as score, company FROM mydata<br />

WHERE CONTAINS(company, 'xy gmbh', FUZZY(0.7, 'textsearch=compare,<br />

stopwordTable=MYSTOPWORDS, stopwordListId=legalform'))<br />

ORDER BY score DESC;<br />

To activate language-specific stopwords, you must provide the language parameter:<br />

SELECT TO_DECIMAL(SCORE(),3,2) as score, company FROM mydata<br />

WHERE CONTAINS(company, 'xy gmbh', FUZZY(0.7, 'textsearch=compare,<br />

stopwordTable=MYSTOPWORDS, stopwordListId=legalform'), language('de'))<br />

ORDER BY score DESC;<br />

Note: In this case, all stopwords where language_code is set to 'de' or empty will be used. Any stopwords<br />

with other language codes will be ignored.<br />

Stopwords are removed from the search term first. In this example, the result set of the search is the same as for<br />

the search '... WHERE CONTAINS(company, 'xy', ...'.<br />

When calculating the score, the fuzzy scores of the non-stopword terms have the biggest influence on the<br />

resulting score. Stopwords in the user input and in the database records are also given less weight than the non-<br />

stopword terms, so records with matching stopwords get a higher score than records with differing or missing<br />

stopwords.<br />

The result of the above example is as follows:<br />

Score Company Comment<br />

1.00 XY GmbH<br />

0.95 XY Missing stopword<br />

0.95 XY Aktiengesellschaft Differing stopword<br />

0.92 XY Gesellschaft mit beschränkter<br />

Haftung<br />

Many differing stopwords<br />

0.78 XY Company Additional non-matching term, no<br />

stopword<br />

The value given for stopwordTable can be any valid SQL identifier as defined in the SQL reference manual. If<br />

schema is omitted, the current schema is used. The following examples all reference the same stopword table.<br />

SET SCHEMA schema1;<br />

SELECT ... WHERE CONTAINS(c, 'xy', FUZZY(0.7,<br />

'stopwordTable=schema1.mystopwords, ...'))...;<br />

SELECT ... WHERE CONTAINS(c, 'xy', FUZZY(0.7,<br />

'stopwordTable="SCHEMA1"."MYSTOPWORDS", ...'))...;<br />

SELECT ... WHERE CONTAINS(c, 'xy', FUZZY(0.7,<br />

'stopwordTable=mystopwords, ...'))...;<br />

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