ISolrSearchEngineSchema.Fields

Syntax

Fields(Type: SearchEngineTargetType): 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.

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.

See also:

ISolrSearchEngineSchema | System and Custom Fields