ISolrFilterCondition.Nested

Fore Syntax

Nested: ISolrFilterConditions;

Fore.NET Syntax

Nested: Prognoz.Platform.Interop.BISearch.ISolrFilterConditions;

Description

The Nested property returns the collection of nested filtering conditions.

Fore Example

It is supposed that the repository is set to work with search service based on Apache Solr. The search service base has indexed data about various repository data source slices. Add links to the BISearch, Fore, Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    SharedParams: ISharedParams;
    SearchEngine: ISolrSearchEngineService;
    Schema: ISolrSearchEngineSchema;
    SearchExecutor: ISearchExecutor;
    SolrContext: ISolrSearchContext;
    Condition1, Condition2: ISolrFilterCondition;
    ConditionValues1, ConditionValues2: ISolrFilterFieldValues;
    Values1, Values2: Array Of Variant;
    SearchContext: ISolrSourceDataSearchContext;
    Results: ISolrSearchResults;
    Result: ISearchResult;
    i: Integer;
Begin
    MB := MetabaseClass.Active;
    //Search and indexing parameters specified for repository
    SharedParams := MB.SpecialObject(MetabaseSpecialObject.SharedParams).Bind As ISharedParams;
    SearchEngine := SharedParams.SearchEngine As ISolrSearchEngineService;
    Schema := SearchEngine.SearchEngineSchema As ISolrSearchEngineSchema;
    SearchExecutor := Schema.SearchExecutor(SearchEngineTargetType.SourceData);
    SolrContext := SearchExecutor.CreateContext As ISolrSearchContext;
    //Filtering parameters
    Condition1 := SolrContext.FilterContext.FilterCondition.Nested.Add;
    Condition1.SolrField := Schema.Fields(SearchEngineTargetType.SourceData).FindById("name");
    Condition1.Operator_ := LogicalOperator.And_;
    ConditionValues1 := Condition1.Values;
    ConditionValues1.Operator_ := LogicalOperator.Or_;
    Values1 := New Variant[2];
    Values1[0] := "Income";
    Values1[1] := "Expense";
    ConditionValues1.Values := Values1;
    //Linked condition
    Condition2 := SolrContext.FilterContext.FilterCondition.Nested.Add;
    Condition2.Operator_ := LogicalOperator.And_;
    Condition2.SolrField := Schema.Fields(SearchEngineTargetType.SourceData).FindById("time");
    ConditionValues2 := Condition2.Values;
    ConditionValues2.Operator_ := LogicalOperator.Or_;
    Values2 := New Variant[2];
    Values2[0] := "2000";
    Values2[1] := "2001";
    ConditionValues2.Values := Values2;
    //Search parameters
    SearchContext := SolrContext As ISolrSourceDataSearchContext;
    SearchContext.Locale := LocaleCodeID.Russian;
    SearchContext.Text := "Russia";
    //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. The search is executed taking into account specified filtering parameters by the name and time fields values. The results are displayed in the development environment console.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example. Along with the assemblies determined in the Fore example, also add a link to the System assembly.

Imports Prognoz.Platform.Interop.BISearch;
Imports Prognoz.Platform.Interop.ForeSystem;
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;
    SearchExecutor: ISearchExecutor;
    SolrContext: ISolrSearchContext;
    Condition1, Condition2: ISolrFilterCondition;
    ConditionValues1, ConditionValues2: ISolrFilterFieldValues;
    Values1: Array = New Object[2] = ["Income""Expense"];
    Values2: Array = New Object[2] = ["2000""2001"];
    SearchContext: ISolrSourceDataSearchContext;
    Results: ISolrSearchResults;
    Result: ISearchResult;
    i: Integer;
Begin
    MB := Params.Metabase;
    //Search and indexing parameters specified for repository
    SharedParams := MB.SpecialObject[MetabaseSpecialObject.msoSharedParams].Bind() As ISharedParams;
    SearchEngine := SharedParams.SearchEngine As ISolrSearchEngineService;
    Schema := SearchEngine.SearchEngineSchema As ISolrSearchEngineSchema;
    //Filtering parameters
    SearchExecutor := Schema.SearchExecutor[SearchEngineTargetType.settSourceData];
    SolrContext := SearchExecutor.CreateContext() As ISolrSearchContext;
    Condition1 := SolrContext.FilterContext.FilterCondition.Nested.Add();
    Condition1.SolrField := Schema.Fields[SearchEngineTargetType.settSourceData].FindById("name");
    Condition1.Operator := LogicalOperator.loAnd;
    ConditionValues1 := Condition1.Values;
    ConditionValues1.Operator := LogicalOperator.loOr;
    ConditionValues1.Values := Values1;
    //Linked condition
    Condition2 := SolrContext.FilterContext.FilterCondition.Nested.Add();
    Condition2.SolrField := Schema.Fields[SearchEngineTargetType.settSourceData].FindById("time");
    ConditionValues2 := Condition2.Values;
    ConditionValues2.Operator := LogicalOperator.loAnd;
    ConditionValues2.Values := Values2;
    //Search parameters
    SearchContext := SolrContext As ISolrSourceDataSearchContext;
    SearchContext.Locale := LocaleCodeID.lcidRussian;
    SearchContext.Text := "Russia";
    //Search
    Results := SearchExecutor.Search(SearchContext) As ISolrSearchResults;
    //View search results
    For i := 0 To Results.Count - 1 Do
        Result := Results.Item[i];
        System.Diagnostics.Debug.WriteLine("Name: """ + Result.Name + """. Description: """ + Result.Description + '"');
        If Result.HighlightedName <> "" Then
            System.Diagnostics.Debug.Indent();
            System.Diagnostics.Debug.WriteLine("Values with highlighted searched value:");
            System.Diagnostics.Debug.WriteLine("Name: """ + Result.HighlightedName + """. Description: """ + Result.HighlightedDescription + '"');
            System.Diagnostics.Debug.Unindent();
        End If;
    End For;
End Sub;

See also:

ISolrFilterCondition