SourceField: ISolrField;
The SourceField property determines the field that is used to create a binding.
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.
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.
See also:
ISolrImportFieldToFieldBinding | ISolrSearchEngineSchema.Fields | System and Custom Fields