ISearchMbObjectResult.Id

Fore Syntax

Id: String;

Fore.NET Syntax

Id: String;

Description

The Id property returns repository object identifier.

Example

It is supposed that the repository is set up to work with search service based on Apache Solr. Search service base has indexed metadata of various repository objects. Add links to the BISearch, Fore, Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    SharedParams: ISharedParams;
    SearchEngine: ISolrSearchEngineService;
    Schema: ISolrSearchEngineSchema;
    SearchExecutor: ISearchExecutor;
    SearchContext: ISolrMbObjectsSearchContext;
    Results: ISolrSearchResults;
    Result: ISearchMbObjectResult;
    i: Integer;
Begin
    MB := MetabaseClass.Active;
    //Search and indexing parameters specified for repository
    SharedParams := MB.SpecialObject(MetabaseSpecialObject.SharedParams).Bind As ISharedParams;
    SearchEngine := SharedParams.SearchEngine As ISolrSearchEngineService;
    Schema := SearchEngine.SearchEngineSchema As ISolrSearchEngineSchema;
    //Search parameters
    Schema.SearchOptions.UseSmartSearch := False;
    SearchExecutor := Schema.SearchExecutor(SearchEngineTargetType.MbObject);
    SearchContext := SearchExecutor.CreateContext As ISolrMbObjectsSearchContext;
    SearchContext.Locale := LocaleCodeID.Russian;
    SearchContext.Text := "Cube 2016";
    //Search
    Results := SearchExecutor.Search(SearchContext) As ISolrSearchResults;
    //View search results
    For i := 0 To Results.Count - 1 Do
        Result := Results.Item(i) As ISearchMbObjectResult;
        Debug.WriteLine(Result.ClassName + '(' + Result.ClassId.ToString + ')');
        If Result.HighlightedClassName <> "" Then
            Debug.WriteLine("Class name with search value highlighting: " + Result.HighlightedClassName);
        End If;
        Debug.Indent;
        Debug.WriteLine("Object: " + Result.Name + '(' + Result.Id + "). Key: " + Result.Key.ToString);
        Debug.WriteLine("Data and time of the last change: " + Result.Timestamp);
        Debug.WriteLine("Information with highlighting of search value:");
        If Result.HighlightedName <> "" Then
            Debug.WriteLine("Name: " + Result.HighlightedName);
        End If;
        If Result.HighlightedId <> "" Then
            Debug.WriteLine("Identifier: " + Result.HighlightedId);
        End If;
        If Result.HighlightedDescription <> "" Then
            Debug.WriteLine("Description: " + Result.HighlightedDescription);
        End If;
        If Result.HighlightedTimestamp <> "" Then
            Debug.WriteLine("Date and time of the last change: " + Result.HighlightedTimestamp);
        End If;
        If Result.HighlightedKey <> "" Then
            Debug.WriteLine("Key: " + Result.HighlightedKey);
        End If;
        Debug.Unindent;
    End For;
End Sub UserProc;

On executing the example the specified value by indexed metadata of repository objects will be searched. Information about found objects is displayed in the development environment console.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example. Along with the assemblies determined in the Fore example, also add a link to the System 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;
    MBClass: MetabaseClass = New MetabaseClassClass();
    SharedParams: ISharedParams;
    SearchEngine: ISolrSearchEngineService;
    Schema: ISolrSearchEngineSchema;
    SearchExecutor: ISearchExecutor;
    SearchContext: ISolrMbObjectsSearchContext;
    Results: ISolrSearchResults;
    Result: ISearchMbObjectResult;
    i: Integer;
Begin
    MB := Params.Metabase;
    //Search and indexing parameters specified for repository
    SharedParams := MB.SpecialObject[MetabaseSpecialObject.msoSharedParams].Bind() As ISharedParams;
    SearchEngine := SharedParams.SearchEngine As ISolrSearchEngineService;
    Schema := SearchEngine.SearchEngineSchema As ISolrSearchEngineSchema;
    //Search parameters
    Schema.SearchOptions.UseSmartSearch := False;
    SearchExecutor := Schema.SearchExecutor[SearchEngineTargetType.settMbObject];
    SearchContext := SearchExecutor.CreateContext() As ISolrMbObjectsSearchContext;
    SearchContext.Locale := LocaleCodeID.lcidRussian;
    SearchContext.Text := "Cube 2016";
    //Search
    Results := SearchExecutor.Search(SearchContext) As ISolrSearchResults;
    //View search results
    For i := 0 To Results.Count - 1 Do
        Result := Results.Item[i] As ISearchMbObjectResult;
        System.Diagnostics.Debug.WriteLine(Result.ClassName + '(' + Result.ClassId.ToString() + ')');
        If Result.HighlightedClassName <> "" Then
            System.Diagnostics.Debug.WriteLine("Class name with highlighted search value: " + Result.HighlightedClassName);
        End If;
        System.Diagnostics.Debug.Indent();
        System.Diagnostics.Debug.WriteLine("Object: " + Result.Name + '(' + Result.Id + ')');
        System.Diagnostics.Debug.WriteLine("Date and time of the last change: " + Result.Timestamp);
        System.Diagnostics.Debug.WriteLine("Information with highlight of search value:");
        If Result.HighlightedName <> "" Then
            System.Diagnostics.Debug.WriteLine("Name: " + Result.HighlightedName);
        End If;
        If Result.HighlightedId <> "" Then
            System.Diagnostics.Debug.WriteLine("Identifier: " + Result.HighlightedId);
        End If;
        If Result.HighlightedDescription <> "" Then
            System.Diagnostics.Debug.WriteLine("Description: " + Result.HighlightedDescription);
        End If;
        If Result.HighlightedTimestamp <> "" Then
            System.Diagnostics.Debug.WriteLine("Date and time of the last change: " + Result.HighlightedTimestamp);
        End If;
        If Result.HighlightedKey <> "" Then
            System.Diagnostics.Debug.WriteLine("Key: " + Result.HighlightedKey);
        End If;
        System.Diagnostics.Debug.Unindent();
    End For;
End Sub;

See also:

ISearchMbObjectResult