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.

11.2 Building SQL Search Queries<br />

In column-oriented tables, you can perform searches using the SQL SELECT statement.<br />

Before building SQL search queries, the following prerequisites must be met:<br />

● The tables you want to search are column-oriented.<br />

● You have created any required views for the tables you want to search.<br />

● You have created any required full text indexes for the columns you want to search.<br />

<strong>SAP</strong> <strong>HANA</strong> supports the standard SQL search syntax and functions for search queries on nearly all visible data<br />

types. You build SQL queries using the SELECT statement, as in the following example:<br />

SELECT * FROM Contacts WHERE ID=1<br />

However, in <strong>SAP</strong> <strong>HANA</strong>, columns of large object types and text have additional requirements. To enable search on<br />

columns of these types, you must ensure the following requirements are met:<br />

● Full text indexes have been created for the search-relevant columns. For columns of type TEXT and<br />

SHORTTEXT, this is done automatically.<br />

● Search queries on the columns use the CONTAINS predicate.<br />

For large object types and text, you build SQL queries using the SELECT statement and CONTAINS predicate, as<br />

in the following example:<br />

SELECT * FROM Documents WHERE CONTAINS (*,'Comment')<br />

To build a search query, proceed as follows:<br />

1. Use the SQL SELECT statement and specify the table or view and column you want to search. If required,<br />

include the CONTAINS predicate.<br />

2. If required, specify scalar functions for the search.<br />

3. Specify the search terms and, optionally, the search type (EXACT, LINGUISTIC, or FUZZY).<br />

Note: If you do not specify a search type, by default, the search query is performed as an exact<br />

search.<br />

For further examples of the syntax used with the SELECT statement, see <strong>SAP</strong> <strong>HANA</strong> SQL Reference<br />

Manual.<br />

Related Links<br />

<strong>SAP</strong> <strong>HANA</strong> SQL Reference Manual: SELECT<br />

11.2.1 Search Queries with CONTAINS<br />

In <strong>SAP</strong> <strong>HANA</strong>, you can search one or multiple columns by creating a query that includes the CONTAINS predicate.<br />

In <strong>SAP</strong> <strong>HANA</strong>, a search query with CONTAINS has a look and feel similar to common Internet search engines.<br />

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