ISolrSearchContext.RelevanceImpactFormula

Syntax

RelevanceImpactFormula: String;

Description

The RelevanceImpactFormula property determines search relevance influence formula.

Comments

A relevance formula is the formula, based on which value significance of indexed fields is determined. The formula can use created fields and different functions. The list of available functions is presented in the Apache Solr help at: https://wiki.apache.org/solr/FunctionQuery. The result of formula calculation must be the integer value, which, to determine relevance, will be multiplied to relevance value of found document. Apache Solr calculates the relevance value of found document.

If the RelevanceImpactFormula property is not set, the formula determined in the ISolrSearchOptions.RelevanceImpactFormula property will be used.

Example

Executing the example requires changes in the Solr configuration file: the rateDataDynamic and rateWeight custom fields are added to the file. The information determining the data role of each record is stored for those fields. Add links to the BISearch, Fore, Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    SharedParams: ISharedParams;
    SearchEngine: ISolrSearchEngineService;
    Schema: ISolrSearchEngineSchema;
    SearchExecutor: ISearchExecutor;
    SearchContext: ISolrSourceDataSearchContext;
    Results: ISolrSearchResults;
    Result: ISearchResult;
    i: Integer;
Begin
    MB := MetabaseClass.Active;
    //Parameters of search and indexing set for repository
    SharedParams := MB.SpecialObject(MetabaseSpecialObject.SharedParams).Bind As ISharedParams;
    SearchEngine := SharedParams.SearchEngine As ISolrSearchEngineService;
    Schema := SearchEngine.SearchEngineSchema As ISolrSearchEngineSchema;
    //Search parameters
    SearchExecutor := Schema.SearchExecutor(SearchEngineTargetType.SourceData);
    SearchContext := SearchExecutor.CreateContext As ISolrSourceDataSearchContext;
    //Relevance formula
    SearchContext.RelevanceImpactFormula := "sum(rateDataDynamic,rateWeight)";
    SearchContext.Locale := LocaleCodeID.Russian;
    SearchContext.Text := "Russia";
    SearchContext.SearchType := SolrSearchType.SearchOnly;
    //Search
    Results := SearchExecutor.Search(SearchContext) As ISolrSearchResults;
    //View search results
    For i := 0 To Results.Count - 1 Do
        Result := Results.Item(i);
        Debug.WriteLine("Name: """ + Result.Name + """. Description: """ + Result.Description + '"');
        If Result.HighlightedName <> "" Then
            Debug.Indent;
            Debug.WriteLine("values with highlighting of searched value:");
            Debug.WriteLine("Name: """ + Result.HighlightedName + """. Description: """ + Result.HighlightedDescription + '"');
            Debug.Unindent;
        End If;
    End For;
End Sub UserProc;

After executing the example the specified value by indexed information about dimension elements will be searched. To search, relevance formula will be determined. According to the formula, more relevant records are those, for which the sum of the rateDataDynamic and rateWeight fields has a greater value. Those values will be the first in the search result. The results are displayed in the development environment console.

See also:

ISolrSearchContext