ISolrSearchEngineSchema.Fields

Fore Syntax

Fields(Type: SearchEngineTargetType): ISolrFields;

Fore.NET Syntax

Fields(Type: Prognoz.Platform.Interop.BISearch.SearchEngineTargetType): Prognoz.Platform.Interop.BISearch.ISolrFields;

Parameters

Type. Purpose of the Solr instance, for which it is necessary to get fields list.

Description

The Fields property returns the collection of fields, for which indexed data is stored.

Fore Example

Executing the example requires changes in the Solr configuration file: the COMMENTS custom field is added to the file, the field is used to search and allows for storing multiple values. Add links to the BiSearch, Dal, Fore, Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    SharedParams: ISharedParams;
    SearchEngine: ISolrSearchEngineService;
    Schema: ISolrSearchEngineSchema;
    Fields: ISolrFields;
    Field: ISolrField;
Begin
    MB := MetabaseClass.Active;
    SharedParams := MB.SpecialObject(MetabaseSpecialObject.SharedParams).Edit As ISharedParams;
    SearchEngine := SharedParams.SearchEngine As ISolrSearchEngineService;
    Schema := SearchEngine.SearchEngineSchema As ISolrSearchEngineSchema;
    //Synchronize custom fields lists
    Fields := Schema.Fields(SearchEngineTargetType.SourceData);
    Field := Fields.AddField("COMMENTS", SolrFieldType.Search);
    Field.DataType := DbDataType.String;
    Field.MultiValue := True;
    Field.IncludeInSearchResult := False;
    (Field As ISolrSearchField).BoostFactor := 9;
    //Save
    SharedParams.SearchEngine := SearchEngine;
    (SharedParams As IMetabaseObject).Save;
End Sub UserProc;

On executing the example in repository search and indexing settings the list of custom fields, for which indexed data is stored, will be changed: the custom field, which is present in the Solr configuration file, will be added to the list.

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.Dal;
Imports Prognoz.Platform.Interop.KeFore;
Imports Prognoz.Platform.Interop.Metabase;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    SharedParams: ISharedParams;
    SearchEngine: ISolrSearchEngineService;
    Schema: ISolrSearchEngineSchema;
    Fields: ISolrFields;
    Field: ISolrField;
Begin
    MB := Params.Metabase;
    SharedParams := MB.SpecialObject[MetabaseSpecialObject.msoSharedParams].Edit() As ISharedParams;
    SearchEngine := SharedParams.SearchEngine As ISolrSearchEngineService;
    Schema := SearchEngine.SearchEngineSchema As ISolrSearchEngineSchema;
    //Synchronize custom fields lists
    Fields := Schema.Fields[SearchEngineTargetType.settSourceData];
    Field := Fields.AddField("COMMENTS", SolrFieldType.sftSearch);
    Field.DataType := DbDataType.ddtString;
    Field.MultiValue := True;
    Field.IncludeInSearchResult := False;
    (Field As ISolrSearchField).BoostFactor := 9;
    //Save
    SharedParams.SearchEngine := SearchEngine;
    (SharedParams As IMetabaseObject).Save();
End Sub;

See also:

ISolrSearchEngineSchema | System and Custom Fields