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.

INSERT INTO housenumbers VALUES ('10-12a');<br />

INSERT INTO housenumbers VALUES ('10a');<br />

INSERT INTO housenumbers VALUES ('10-14');<br />

INSERT INTO housenumbers VALUES ('9');<br />

SELECT TO_DECIMAL(SCORE(),3,2), *<br />

FROM housenumbers<br />

WHERE CONTAINS(housenumber, '5', FUZZY(0.8))<br />

ORDER BY TO_DECIMAL(SCORE(),3,2) DESC;<br />

SELECT TO_DECIMAL(SCORE(),3,2), *<br />

FROM housenumbers<br />

WHERE CONTAINS(housenumber, 'Nr. 5', FUZZY(0.8))<br />

ORDER BY TO_DECIMAL(SCORE(),3,2) DESC;<br />

SELECT TO_DECIMAL(SCORE(),3,2), *<br />

FROM housenumbers<br />

WHERE CONTAINS(housenumber, '8a-12', FUZZY(0.8))<br />

ORDER BY TO_DECIMAL(SCORE(),3,2) DESC;<br />

SELECT TO_DECIMAL(SCORE(),3,2), *<br />

FROM housenumbers<br />

WHERE CONTAINS(housenumber, '10-12', FUZZY(0.8))<br />

ORDER BY TO_DECIMAL(SCORE(),3,2) DESC;<br />

SELECT TO_DECIMAL(SCORE(),3,2), *<br />

FROM housenumbers<br />

WHERE CONTAINS(housenumber, '9 in the BACKYARD', FUZZY(0.8))<br />

ORDER BY TO_DECIMAL(SCORE(),3,2) DESC;<br />

Use Case Fuzzy Search - Postcodes<br />

Postcodes in almost all countries are ordered by region. This means that if the leading characters of the<br />

postcodes of two different addresses are the same, the addresses are near to each other. In Germany, for<br />

example, addresses within large cities share the first or even the first two digits of their postcode.<br />

The only exception known to the development team is Cambodia, where postcodes are not ordered by region.<br />

When doing a fuzzy search on addresses, it makes sense to return a higher score for postcodes that are 'near' to a<br />

given user input than for postcodes that are 'far away' from the user input. It makes sense to give a higher weight<br />

to the leading characters and a lower weight to the trailing characters of the postcode.<br />

Valid addresses may contain a country code in front of the postcode (for example, 'D-12345' or 'DE-12345' for a<br />

German address). This is also supported by the fuzzy postcode search.<br />

Score Calculation<br />

Before the fuzzy score is calculated, the postcode strings are standardized.<br />

1. Country codes are separated from the postcode strings. Country codes in this case consist of one to three<br />

276<br />

letters (a-z only, no numbers) at the beginning of the postcode, followed by a minus sign. Longer words are<br />

not considered a country code because postal standards do not allow country names in front of the postcode.<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!