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.

Only one of these errors is allowed. Dates with more than one error are not considered similar, so the score is 0.0.<br />

Dates with a score less than the fuzzySimilarity parameter are not returned.<br />

Example:<br />

SELECT TO_DECIMAL(SCORE(),3,2) AS score, * FROM dates<br />

WHERE CONTAINS(dateofbirth, '2000-01-10', FUZZY(0.8))<br />

ORDER BY score DESC;<br />

For this example we get:<br />

2000-01-09 -> 0.00 (not returned to the user)<br />

2000-01-10 -> 1.00<br />

2000-01-11 -> 0.90<br />

2000-01-12 -> 0.90<br />

...<br />

2000-01-21 -> 0.00 (not returned to the user)<br />

...<br />

2000-10-01 -> 0.80<br />

Score Calculation for Date Distance<br />

The maximum allowed distance between dates can be defined using the search option 'maxDateDistance', which<br />

defines a number of days.<br />

The default for this option is 0, that is, the feature is disabled. This is shown in the following example:<br />

SELECT TO_DECIMAL(SCORE(),3,2) AS score, * FROM dates<br />

WHERE CONTAINS(dateofbirth, '2000-01-10', FUZZY(0.95, 'maxDateDistance=5'))<br />

ORDER BY score DESC;<br />

This query returns all dates between 2000-01-05 and 2000-01-15.<br />

The fuzzy score for dates is calculated as follows:<br />

The identical date gets a score of 1.0.<br />

The date that is maxDateDistance days away from the search input gets a score that equals the fuzzySimilarity<br />

parameter (0.95 in the example above).<br />

The score of dates between the identical date and maxDateDistance is calculated as a linear function between the<br />

two dates defined above. In other words, for each day the score is reduced by ((1-fuzzySimilarity) /<br />

maxDateDistance).<br />

For dates outside the range of maxDateDistance, the score is 0.0.<br />

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

Enabling Search<br />

P U B L I C<br />

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

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

Saved successfully!

Ooh no, something went wrong!