Export (0) Print
Expand All

ISearchQueryHelper::GenerateSQLFromUserQuery method

Generates a Structured Query Language (SQL) query based on a client-supplied query string expressed in either Advanced Query Syntax (AQS) or Natural Query Syntax (NQS).

Syntax


HRESULT GenerateSQLFromUserQuery(
  [in]           LPCWSTR pszQuery,
  [out, retval]  LPWSTR *ppszSQL
);

Parameters

pszQuery [in]

Type: LPCWSTR

A pointer to a null-terminated Unicode string containing a query in AQS or NQS.

ppszSQL [out, retval]

Type: LPWSTR*

Receives the address of a pointer to a SQL query string based on the query in the pszQuery parameter.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

This method generates SQL in the following form:

SELECT <QuerySelectColumns> FROM <CatalogName that created query helper>
    WHERE <Result of interpreting the User query passed into this function according to QuerySyntax>
          [ AND|OR <QueryWhereRestrictions>]

The SQL generation uses the settings specified in ISearchQueryHelper::put_QueryTermExpansion, ISearchQueryHelper::put_QueryContentProperties, and ISearchQueryHelper::put_QueryContentLocale.

ISearchQueryHelper::GenerateSQLFromUserQuery uses regional locale settings. However, ISearchQueryHelper does not use the regional locale settings. As a result, there are inconsistencies in the SQL returned from ISearchQueryHelper::GenerateSQLFromUserQuery and ISearchQueryHelper for region specific settings such as date formats. For example, if you set the locale for date/time to something other than the system locale, such as en-CA if the system locale is en-US, and enter Toybox -m -i "date:3/7/2008" -Y -s, the SQL returned will differ. The SQL from ISearchQueryHelper::GenerateSQLFromUserQuery will have parsed 3/7/2008 according to en-CA (seeking items dated 3rd of July, 2008) while the SQL from ISearchQueryHelper will have parsed 3/7/2008 according to en-US (seeking items dated 7th of March, 2008).

The DSearch code sample, available on Code Gallery and the Windows 7 SDK, demonstrates how to create a class for a static console application to query Windows Search using the Microsoft.Search.Interop assembly for ISearchQueryHelper.

Requirements

Minimum supported client

Windows XP with SP2, Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2003 with SP1 [desktop apps only]

Redistributable

Windows Desktop Search (WDS) 3.0

Header

Searchapi.h

IDL

Searchquery.idl

See also

ISearchQueryHelper
ISearchQueryHelper::get_QuerySyntax
Querying the Index Programmatically
Querying the Index with Windows Search SQL Syntax

 

 

Community Additions

ADD
Show:
© 2014 Microsoft