ISolrSearchResults.FacetSearchResults

Fore Syntax

FacetSearchResults: ISolrFacetSearchResults;

Fore.NET Syntax

FacetSearchResults: Prognoz.Platform.Interop.BISearch.ISolrFacetSearchResults;

Description

The FacetSearchResults property returns the result of faceted search.

Comments

The result of faceted search will be available if in search context the ISolrSearchContext.SearchType property was set to SolrSearchType.FacetOnly or SolrSearchType.FacetAndSearch.

Fore Example

It is supposed that the repository is set up to work with search service based on Apache Solr. 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;
    SearchContext: ISolrSourceDataSearchContext;
    Results: ISolrSearchResults;
    FacetResults: ISolrFacetSearchResults;
    FacetResult: ISolrFacetFieldResults;
    i, j: 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;
    //Search parameters
    SearchExecutor := Schema.SearchExecutor(SearchEngineTargetType.SourceData);
    SearchContext := SearchExecutor.CreateContext As ISolrSourceDataSearchContext;
    SearchContext.Locale := LocaleCodeID.Russian;
    SearchContext.Text := "Cube";
    SearchContext.SearchType := SolrSearchType.FacetOnly;
    //Search
    Results := SearchExecutor.Search(SearchContext) As ISolrSearchResults;
    FacetResults := Results.FacetSearchResults;
    //View faceted search results
    For i := 0 To FacetResults.Count - 1 Do
        FacetResult := FacetResults.Item(i);
        Debug.WriteLine("Field: " + FacetResult.Id + ". Values: ");
        Debug.Indent;
        For j := 0 To FacetResult.Count - 1 Do
            Debug.WriteLine("Number of faceted results: " + FacetResult.Item(j).FacetCount.ToString +
                ". Value of faceted field: " + FacetResult.Item(j).FacetValue);
        End For;
        Debug.Unindent;
    End For;
End Sub UserProc;

After executing the example the specified value by indexed information about dimension elements will be searched. The found values are grouped by faceted fields values. After search only faceted results are available containing general information about the number of found data slices.

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;
    SearchContext: ISolrSourceDataSearchContext;
    Results: ISolrSearchResults;
    FacetResults: ISolrFacetSearchResults;
    FacetResult: ISolrFacetFieldResults;
    i, j: 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;
    //Search parameters
    SearchExecutor := Schema.SearchExecutor[SearchEngineTargetType.settSourceData];
    SearchContext := SearchExecutor.CreateContext() As ISolrSourceDataSearchContext;
    SearchContext.Locale := LocaleCodeID.lcidRussian;
    SearchContext.Text := "Value";
    SearchContext.SearchType := SolrSearchType.sstFacetOnly;
    //Search
    Results := SearchExecutor.Search(SearchContext) As ISolrSearchResults;
    FacetResults := Results.FacetSearchResults;
    //View faceted search results
    For i := 0 To FacetResults.Count - 1 Do
        FacetResult := FacetResults.Item[i];
        System.Diagnostics.Debug.WriteLine("Field: " + FacetResult.Id + ". Values: ");
        System.Diagnostics.Debug.Indent();
        For j := 0 To FacetResult.Count - 1 Do
            System.Diagnostics.Debug.WriteLine("Number of faceted results: " + FacetResult.Item[j].FacetCount.ToString() +
                ". Value of faceted field: " + FacetResult.Item[j].FacetValue);
        End For;
        System.Diagnostics.Debug.Unindent();
    End For;
End Sub;

See also:

ISolrSearchResults