ISearchEngineImportScheduledTask.ImportContext

Fore.NET Syntax

ImportContext[Type: Prognoz.Platform.Interop.BISearch.SearchEngineTargetType]: Prognoz.Platform.Interop.BISearch.ISearchEngineImportContext;

Parameters

Type. Indexed data type.

Description

The ImportContext property determines a context with object indexing settings.

IMPORTANT. Because of the existing features of the Fore language implementation and use of multi-thread mode on indexing, task parameter setting with code in the Fore language is not supported. Develop in the Fore.NET language.

Fore.NET Example

Executing the example requires that the repository contains a scheduled tasks container with the TASK_CONTAINER identifier and a standard cube with the STD_CUBE identifier. The cube has the INDICATORS dimension with a list of various factors, the COUNTRY dimension with a list of countries, the FACTS facts dimension and a calendar dimension.

Imports Prognoz.Platform.Interop.BISearch;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Metabase;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    Task: ISearchEngineImportScheduledTask;
    SearchEngine: ISolrSearchEngineService;
    ImportContext: ISourceDataImportContext;
    SolrContext: ISolrImportContext;
    Locales: Array = New Integer[1] = [LocaleCodeID.lcidRussian As Integer];
    Cube: ICubeModel;
    CubeDimensions: ICubeModelDimensions;
    CubeDimension: IDimensionModel;
    SourceInfo: ISourceDataImportInfo;
    DestinationInfo: ISourceDataImportDestinationInfo;
    DimSS: IDimSelectionSet;
    DimS: IDimSelection;
    i: Integer;
Begin
    MB := Params.Metabase;
    //Create a task
    CrInfo := MB.CreateCreateInfo();
    CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_TASK_SEARCHENGINE_IMPORT As Integer;
    CrInfo.Name := "Standard cube indexing";
    CrInfo.Parent := Mb.ItemById["TASK_CONTAINER"];
    Task := MB.CreateObject(CrInfo).Edit() As ISearchEngineImportScheduledTask;
    //Get search service
    SearchEngine := Task.Engine As ISolrSearchEngineService;
    //Context to index objects
    SolrContext := SearchEngine.SearchEngineSchema.ImportExecutor[SearchEngineTargetType.settSourceData].CreateContext() As ISolrImportContext;
    SolrContext.CleanType := SolrImportCleanType.sictSpecified;
    SolrContext.Locales := Locales;
    //Indexed object - standard cube
    Cube := MB.ItemById["STD_CUBE"].Bind() As ICubeModel;
    CubeDimensions := Cube.Destinations.DefaultDestination.Dimensions;
    //Add a cube and set up indexing parameters
    ImportContext := (SolrContext As ISourceDataImportContext);
    SourceInfo := ImportContext.SourceInfos.Add(Cube);
    DestinationInfo := SourceInfo.DestinationInfos.Add(Cube.Destinations.DefaultDestination);
    //Indexing parameters of display version
    //Group calendar elements by levels
    DestinationInfo.GroupByDl := True;
    //Full indexing
    DestinationInfo.ImportMode := SourceImportMode.simFull;
    //Form lists of dimensions
    For i := 0 To CubeDimensions.Count - 1 Do
        CubeDimension := CubeDimensions.Item[i];
        Select Case (CubeDimension As IMetabaseObject).Id
            Case "FACTS": DestinationInfo.FreeDimensions.Add(CubeDimension);
            Case "INDICATORS""COUNTRY": DestinationInfo.KeyWordsDimensions.Add(CubeDimension);
        End Select;
    End For;
    //Set selection by dimensions
    DimSS := DestinationInfo.SelectionSet;
    For i := 0 To DimSS.Count - 1 Do
        DimS := DimSS.Item[i];
        Select Case DimS.Dimension.Ident
            Case "FACTS""INDICATORS":
                DimS.SelectAll();
            Case "COUNTRY":
                DimS.SelectElement(0False);
                DimS.SelectElement(1False);
        End Select;
    End For;
    //Install context to task
    Task.ImportContext[SearchEngineTargetType.settSourceData] := ImportContext;
    //Save task
    (Task As IMetabaseObject).Save();
End Sub;

On executing the example a new task updating search service will be created in scheduled tasks container. The specified standard cube will be added to the task, its dimensions will be set up.

See also:

ISearchEngineImportScheduledTask