ISolrImportFieldToFieldBinding.SourceField

Fore Syntax

SourceField: ISolrField;

Fore.NET Syntax

SourceField: Prognoz.Platform.Interop.BISearch.ISolrField;

Description

The SourceField property determines the field that is used to create a binding.

Comments

If a binding is created for the field with data, the SourceField property value must be set to the field with metadata. If a binding is created for the field with metadata, the SourceField property value must be set to the field with data. The binding can be created to both system and custom fields. The list of all fields can be obtained in the ISolrSearchEngineSchema.Fields property.

Fore Example

Executing the example requires that the repository contains a scheduled tasks container with the TASK_CONTAINER identifier. The first task in the container is used to refresh search index. Indexing parameters for standard cube are determined in the task settings. The TAG custom field is created in indexing settings and repository search.

Sub UserProc;
Var
    MB: IMetabase;
    Container: IScheduledTasksContainer;
    Task: ISearchEngineImportScheduledTask;
    EngineSchema: ISolrSearchEngineSchema;
    ImportContext: ISourceDataImportContext;
    SourceInfo: ISourceDataImportInfo;
    DestinationInfo: ISourceDataImportDestinationInfo;
    FieldBindings: ISolrImportFieldBindings;
    FieldBinding: ISolrImportFieldToFieldBinding;
    Field: ISolrField;
Begin
    MB := MetabaseClass.Active;
    //Get task
    Container := MB.ItemById("TASK_CONTAINER").Bind As IScheduledTasksContainer;
    Task := Container.Tasks.Item(0).Edit As ISearchEngineImportScheduledTask;
    //Context to index objects
    EngineSchema := Task.Engine.SearchEngineSchema As ISolrSearchEngineSchema;
    ImportContext := Task.ImportContext(SearchEngineTargetType.SourceData) As ISourceDataImportContext;
    //Get cube indexing parameters
    SourceInfo := ImportContext.SourceInfos.Item(0);
    DestinationInfo := SourceInfo.DestinationInfos.Item(0);
    //Parameters of filling in custom fields
    FieldBindings := (DestinationInfo As ISolrSourceDataImportDestinationInfo).FieldBindings;
    //Field, for which parameters will be set
    Field := EngineSchema.Fields(SearchEngineTargetType.SourceData).FindById("TAG");
    //Fill in from values of another field
    FieldBinding := FieldBindings.AddBinding(SolrFieldBindingType.ByField, Field) As ISolrImportFieldToFieldBinding;
    FieldBinding.SourceField := EngineSchema.Fields(SearchEngineTargetType.MbObject).FindById("name");
    //Install context to task
    Task.ImportContext(SearchEngineTargetType.SourceData) := ImportContext;
    //Save task
    (Task As IMetabaseObject).Save;
End Sub UserProc;

On executing the example filling in parameters of the TAG custom field values will be set: the name metadata field values will be placed as a field value.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

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

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    Container: IScheduledTasksContainer;
    Task: ISearchEngineImportScheduledTask;
    EngineSchema: ISolrSearchEngineSchema;
    ImportContext: ISourceDataImportContext;
    SourceInfo: ISourceDataImportInfo;
    DestinationInfo: ISourceDataImportDestinationInfo;
    FieldBindings: ISolrImportFieldBindings;
    FieldBinding: ISolrImportFieldToFieldBinding;
    Field: ISolrField;
Begin
    MB := Params.Metabase;
    //Get task
    Container := MB.ItemById["TASK_CONTAINER"].Bind() As IScheduledTasksContainer;
    Task := Container.Tasks.Item[0].Edit() As ISearchEngineImportScheduledTask;
    //Context to index objects
    EngineSchema := Task.Engine.SearchEngineSchema As ISolrSearchEngineSchema;
    ImportContext := Task.ImportContext[SearchEngineTargetType.settSourceData] As ISourceDataImportContext;
    //Get cube indexing parameters
    SourceInfo := ImportContext.SourceInfos.Item[0];
    DestinationInfo := SourceInfo.DestinationInfos.Item[0];
    //Parameters of filling in custom fields
    FieldBindings := (DestinationInfo As ISolrSourceDataImportDestinationInfo).FieldBindings;
    //Field, for which parameters will be set
    Field := EngineSchema.Fields[SearchEngineTargetType.settSourceData].FindById("TAG");
    //Fill in from dimension attribute values
    FieldBinding := FieldBindings.AddBinding(SolrFieldBindingType.sfbtByField, Field) As ISolrImportFieldToFieldBinding;
    FieldBinding.SourceField := EngineSchema.Fields[SearchEngineTargetType.settMbObject].FindById("name");
    //Install context to task
    Task.ImportContext[SearchEngineTargetType.settSourceData] := ImportContext;
    //Save task
    (Task As IMetabaseObject).Save();
End Sub;

See also:

ISolrImportFieldToFieldBinding | ISolrSearchEngineSchema.Fields | System and Custom Fields