ISearchMbObjectResult.Id

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.

See also:

ISearchMbObjectResult