ItemsOnPage: Integer;
The ItemsOnPage property determines the number of results available on one page.
After search, Solr splits all results into different pages. The number of results on one page is set in the ItemsOnPage property. The number of the page to be loaded is determined in the ISolrSearchContext.Page property.
It is supposed that the repository is set to work with search service based on Apache Solr. Search service base contains indexed metadata of various repository objects. 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;
//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;
//Number of results on one page
SearchContext.ItemsOnPage := 10;
//Number of loaded page
SearchContext.Page := 0;
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 different parameters (search type, language, number of results on one page) will be determined. From all found values only the first page with ten search results will be loaded. The results are displayed in the development environment console.
See also: