ISolrSearchResults.FacetSearchResults

Syntax

FacetSearchResults: 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.

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.

See also:

ISolrSearchResults