Execute method: SearchQuery class

Syntax

Execute(start, size)

Description

Use this method to execute the search query on the search engine. The Execute method returns search results beginning at the document number specified by start, and returns a maximum number of results specified by size.

The Execute method uses the following SearchQuery class properties:

  • Categories

    Note:

    If this property is undefined, the query will be executed against all search categories.

  • Language

    Note:

    If no value is specified, the query will be executed against all languages.

  • QueryText

    Note:

    If no value is specified, then all documents in the index are returned.

Note:

This is an abstract method.

Parameters

Parameter Description

start

Specifies an integer representing the first document of the returned results. This parameter must be greater than or equal to 1.

If start exceeds the total number of documents in the index or the search engine-specified maximum number of results, then zero results are returned.

size

Specifies the maximum size of the result set as an integer. This parameter should be greater than or equal to 1.

If size is set to 0, then 10 documents are returned.

Returns

A SearchResultCollection object.

Example

import PT_SEARCH:SearchFactory;
import PT_SEARCH:SearchQueryService;
import PT_SEARCH:SearchQuery;
import PT_SEARCH:SearchResultCollection;

/* Instantiate the SearchQuery object           */

Local PT_SEARCH:SearchFactory &factory = create PT_SEARCH:SearchFactory();
Local PT_SEARCH:SearchQueryService &svc = &factory.CreateQueryService("default");
Local PT_SEARCH:SearchQuery &srchQuery = &svc.CreateQuery();

/* Initialize the search query                                           */

&srchQuery.QueryText = "some text";
&srchQuery.Language = &lang_cd;
&srchQuery.MarkDuplicates = False;
&srchQuery.RemoveDuplicates = False;

/* Execute the search query                                              */

Local number &start = 1;
Local number &size = 10;
Local PT_SEARCH:SearchResultCollection &results = &srchQuery.Execute(&start,⇒
 &size);

/* Re-execute the search query to return the next 10 results             */

&start = &start + &size;
&results = &srchQuery.Execute(&start, &size);