Package org.ctan.site.services.search
Class SearchService
java.lang.Object
org.ctan.site.services.search.base.IndexingBase
org.ctan.site.services.search.SearchService
The class
SearchingService implements a service to perform a
full-text search.
Configuration
This service can be configured via the global Dropwizard configuration filesrc/main/resources/ctan.yml. The
following configuration items are recognized:
- search.directory
- This configuration item contains the absolute path to the directory in which the sub-directories for the Lucene index files reside.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe classRecommendationTocontains the definition of the transport object for a recommendation. -
Constructor Summary
ConstructorsConstructorDescriptionSearchService(@NonNull CtanConfiguration.IndexConfig config) This is the constructor forSearchService. -
Method Summary
Modifier and TypeMethodDescriptionfind(@NonNull QueryContainer query) Perform a query.recommendations(String packageName, String locale, int maxNumber) This method retrieves a list of recommendations for a given package.Methods inherited from class org.ctan.site.services.search.base.IndexingBase
checkIndexDirectory, directory, indexPath, open, open
-
Constructor Details
-
SearchService
public SearchService(@NonNull @NonNull CtanConfiguration.IndexConfig config) throws FileNotFoundException This is the constructor forSearchService.- Parameters:
config- the configuration- Throws:
FileNotFoundException- in case that one of the index directories does not exist
-
-
Method Details
-
find
public QueryContainer find(@NonNull @NonNull QueryContainer query) throws org.apache.lucene.index.CorruptIndexException, IOException, org.apache.lucene.queryparser.classic.ParseException Perform a query.- Parameters:
query- the query- Returns:
- the query container
- Throws:
IOException- in case of an I/O errororg.apache.lucene.index.CorruptIndexException- in case of an errororg.apache.lucene.queryparser.classic.ParseException- in case of an error
-
recommendations
public List<SearchService.RecommendationTo> recommendations(String packageName, String locale, int maxNumber) throws org.apache.lucene.index.CorruptIndexException, IOException This method retrieves a list of recommendations for a given package. The list contains a transport object for each hit with the following entries:- path
- The path to the package description
- display
- The short name of the package
- title
- The title – currently in English
- score
- The score as float.
- Parameters:
packageName- the name of the base packagelocale- the languagemaxNumber- the maximal number results to be returned- Returns:
- the list of recommendations
- Throws:
IOException- in case of an I/O errororg.apache.lucene.index.CorruptIndexException- in case of an error
-