ISearchSourceDataResult.SourceMetadata

Syntax

SourceMetadata: ISourceMetadata;

Description

The SourceMetadata property returns data source metadata.

Example

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

Sub UserProc;
Var
    MB: IMetabase;
    SharedParams: ISharedParams;
    SearchEngine: ISolrSearchEngineService;
    Schema: ISolrSearchEngineSchema;
    SearchExecutor: ISearchExecutor;
    SearchContext: ISolrSourceDataSearchContext;
    Results: ISolrSearchResults;
    Result: ISearchSourceDataResult;
    Source: ISourceMetadata;
    Selections: ISearchDimSelectionSet;
    Selection: ISearchDimSelection;
    Elements: ISearchDimSelectionElements;
    Element: ISearchDimSelectionElement;
    Calendars: ICalendarInfos;
    Calendar: ICalendarInfo;
    MDesc: IMetabaseObjectDescriptor;
    i, j: 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
    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 source information for the first search result
    Result := Results.Item(0As ISearchSourceDataResult;
    Source := Result.SourceMetadata;
    Debug.WriteLine("Slice name: " + Result.Name);
    Debug.WriteLine("Source: " + Source.SourceName + '(' + Source.SourceId + ')');
    Debug.WriteLine("Object type: " + MetabaseClass.CommonClassName(Source.SourceClassId As MetabaseObjectClass));
    If Source.HighlightedSourceName.Length > 0 Then
        Debug.WriteLine("Name with search value highlighting: " + Source.HighlightedSourceName);
    End If;
    Debug.WriteLine("Selection by indexed dimensions:");
    Debug.Indent;
    //Dimension selection, by which slice is formed
    Selections := Source.Selection;
    For i := 0 To Selections.Count - 1 Do
        Selection := Selections.Item(i);
        Debug.Write("Dimension key: " + Selection.DimensionKey.ToString + ". Elements: ");
        Elements := Selection.Elements;
        For j := 0 To Elements.Count - 1 Do
            Element := Elements.Item(j);
            Debug.Write(Element.Name + '(' + Element.Key + ") ");
        End For;
        Debug.WriteLine("");
    End For;
    Debug.Unindent;
    //Selection of free dimensions, if available
    If Source.FreeDimensionsSelection.Count <> 0 Then
        Debug.WriteLine("Free dimensions selection:");
        Debug.Indent;
        Selections := Source.FreeDimensionsSelection;
        For i := 0 To Selections.Count - 1 Do
            Selection := Selections.Item(i);
            Debug.Write("Dimension key: " + Selection.DimensionKey.ToString + ". Elements: ");
            Elements := Selection.Elements;
            For j := 0 To Elements.Count - 1 Do
                Element := Elements.Item(j);
                Debug.Write(Element.Name + '(' + Element.Key + ") ");
            End For;
            Debug.WriteLine("");
        End For;
        Debug.Unindent;
    End If;
    //Information about calendar dimensions
    Calendars := Source.CalendarInfo;
    For i := 0 To Calendars.Count - 1 Do
        Calendar := Calendars.Item(i);
        MDesc := MB.Item(Calendar.Key);
        Debug.WriteLine("Dictionary in the base of calendar dimension: " + MDesc.Name + '(' + MDesc.Id + ')');
        Debug.WriteLine("Dates, for which data is available: " + Calendar.DateStart.ToString + " - " +
            Calendar.DateEnd.ToString);
    End For;
End Sub UserProc;

After executing the example the specified value by indexed information about dimension elements will be searched. From the first obtained result you will get information about data source, to which the slice belongs. Various information about source selection will be displayed in the development environment console.

See also:

ISearchSourceDataResult