ISearchExecutor.Search

Fore Syntax

Search(Context: ISearchEngineSearchContext): ISearchResults;

Fore.NET Syntax

Search(Context: Prognoz.Platform.Interop.BISearch.ISearchEngineSearchContext): Prognoz.Platform.Interop.BISearch.ISearchResults;

Parameters

Context. Context with search parameters.

Description

The Search method executes the search and returns result set of records satisfying to selected conditions.

Fore Example

It is supposed that the repository is set to work with search service based on Apache Solr. The search service base has indexed data about various repository data source slices. Connect the BISearch, Fore, Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    SharedParams: ISharedParams;
    SearchEngine: ISolrSearchEngineService;
    Schema: ISolrSearchEngineSchema;
    SearchExecutor: ISearchExecutor;
    SearchContext: ISolrSourceDataSearchContext;
    Results: ISolrSearchResults;
    Result: ISearchResult;
    i: Integer;
Begin
    MB := MetabaseClass.Active;
    //Parameters of search and indexing set for repository
    SharedParams := MB.SpecialObject(MetabaseSpecialObject.SharedParams).Bind As ISharedParams;
    SearchEngine := SharedParams.SearchEngine As ISolrSearchEngineService;
    Schema := SearchEngine.SearchEngineSchema As ISolrSearchEngineSchema;
    //Search parameters
    SearchExecutor := Schema.SearchExecutor(SearchEngineTargetType.SourceData);
    SearchContext := SearchExecutor.CreateContext As ISolrSourceDataSearchContext;
    SearchContext.Locale := LocaleCodeID.Russian;
    SearchContext.Text := "Russia";
    //Search
    Results := SearchExecutor.Search(SearchContext) As ISolrSearchResults;
    //View search results
    For i := 0 To Results.Count - 1 Do
        Result := Results.Item(i);
        Debug.WriteLine("Slice name: """ + Result.Name + """. Description: """ + Result.Description + '"');
        If Result.HighlightedName <> "" Then
            Debug.Indent;
            Debug.WriteLine("values with highlighting of searching value:");
            Debug.WriteLine("Slice name: """ + Result.HighlightedName + """. Description: """ + Result.HighlightedDescription + '"');
            Debug.Unindent;
        End If;
    End For;
End Sub UserProc;

After executing the example the specified value by indexed information about dimension elements will be searched. The results are displayed in development environment console.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example. Except assemblies determined in the Fore Example, connect also the ForeSystem assembly.

Imports Prognoz.Platform.Interop.BISearch;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.KeFore;
Imports Prognoz.Platform.Interop.Metabase;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    SharedParams: ISharedParams;
    SearchEngine: ISolrSearchEngineService;
    Schema: ISolrSearchEngineSchema;
    SearchExecutor: ISearchExecutor;
    SearchContext: ISolrSourceDataSearchContext;
    Results: ISolrSearchResults;
    Result: ISearchResult;
    i: Integer;
Begin
    MB := Params.Metabase;
    //Parameters of search and indexing set for repository
    SharedParams := MB.SpecialObject[MetabaseSpecialObject.msoSharedParams].Bind() As ISharedParams;
    SearchEngine := SharedParams.SearchEngine As ISolrSearchEngineService;
    Schema := SearchEngine.SearchEngineSchema As ISolrSearchEngineSchema;
    //Search parameters
    SearchExecutor := Schema.SearchExecutor[SearchEngineTargetType.settSourceData];
    SearchContext := SearchExecutor.CreateContext() As ISolrSourceDataSearchContext;
    SearchContext.Locale := LocaleCodeID.lcidRussian;
    SearchContext.Text := "Russia";
    //Search
    Results := SearchExecutor.Search(SearchContext) As ISolrSearchResults;
    //View search results
    For i := 0 To Results.Count - 1 Do
        Result := Results.Item[i];
        System.Diagnostics.Debug.WriteLine("Slice name: """ + Result.Name + """. Description: """ + Result.Description + '"');
        If Result.HighlightedName <> "" Then
            System.Diagnostics.Debug.Indent();
            System.Diagnostics.Debug.WriteLine("Values with highlighted searched value:");
            System.Diagnostics.Debug.WriteLine("Slice name: """ + Result.HighlightedName + """. Description: """ + Result.HighlightedDescription + '"');
            System.Diagnostics.Debug.Unindent();
        End If;
    End For;
End Sub;

See also:

ISearchExecutor