Package org.apache.maven.index
Class DefaultQueryCreator
- java.lang.Object
-
- org.apache.maven.index.DefaultQueryCreator
-
- All Implemented Interfaces:
QueryCreator
@Singleton @Named public class DefaultQueryCreator extends java.lang.Object implements QueryCreator
A defaultQueryCreatorconstructs Lucene query for provided query text.By default wildcards are created such as query text matches beginning of the field value or beginning of the class/package name segment for
NAMESfield. But it can be controlled by using special markers:- * - any character
- '^' - beginning of the text
- '$' or '<' or ' ' end of the text
- junit - matches junit and junit-foo, but not foo-junit
- *junit - matches junit, junit-foo and foo-junit
- ^junit$ - matches junit, but not junit-foo, nor foo-junit
-
-
Field Summary
Fields Modifier and Type Field Description private org.slf4j.Loggerloggerprivate NexusAnalyzernexusAnalyzer-
Fields inherited from interface org.apache.maven.index.QueryCreator
ROLE
-
-
Constructor Summary
Constructors Constructor Description DefaultQueryCreator()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description org.apache.lucene.search.QueryconstructQuery(java.lang.String field, java.lang.String query)Deprecated.org.apache.lucene.search.QueryconstructQuery(Field field, java.lang.String query, SearchType type)Constructs query by parsing the query string, using field as default field.org.apache.lucene.search.QueryconstructQuery(Field field, SearchExpression expression)Constructs query by parsing the query string, using field as default field.org.apache.lucene.search.QueryconstructQuery(Field field, IndexerField indexerField, java.lang.String query, SearchType type)protected intcountTerms(IndexerField indexerField, java.lang.String query)protected org.slf4j.LoggergetLogger()org.apache.lucene.search.QuerylegacyConstructQuery(java.lang.String field, java.lang.String query)IndexerFieldselectIndexerField(Field field, SearchType type)Performs a selection of the appropriate IndexerField belonging to proper Field.
-
-
-
Field Detail
-
logger
private final org.slf4j.Logger logger
-
nexusAnalyzer
private NexusAnalyzer nexusAnalyzer
-
-
Method Detail
-
getLogger
protected org.slf4j.Logger getLogger()
-
selectIndexerField
public IndexerField selectIndexerField(Field field, SearchType type)
Description copied from interface:QueryCreatorPerforms a selection of the appropriate IndexerField belonging to proper Field.- Specified by:
selectIndexerFieldin interfaceQueryCreator- Returns:
-
constructQuery
public org.apache.lucene.search.Query constructQuery(Field field, SearchExpression expression) throws org.apache.lucene.queryparser.classic.ParseException
Description copied from interface:QueryCreatorConstructs query by parsing the query string, using field as default field. This method should be use to construct queries (single term or phrase queries) against single field.- Specified by:
constructQueryin interfaceQueryCreator- Returns:
- Throws:
org.apache.lucene.queryparser.classic.ParseException- if query parsing is unsuccessful.
-
constructQuery
public org.apache.lucene.search.Query constructQuery(Field field, java.lang.String query, SearchType type) throws org.apache.lucene.queryparser.classic.ParseException
Description copied from interface:QueryCreatorConstructs query by parsing the query string, using field as default field. This method should be use to construct queries (single term or phrase queries) against single field.- Specified by:
constructQueryin interfaceQueryCreator- Returns:
- Throws:
org.apache.lucene.queryparser.classic.ParseException- if query parsing is unsuccessful.
-
constructQuery
@Deprecated public org.apache.lucene.search.Query constructQuery(java.lang.String field, java.lang.String query)Deprecated.Description copied from interface:QueryCreatorDeprecated. Avoid it's use! Constructs query against single field, using it's "best effort" approach to perform parsing, but letting caller to apply it's (usually wrong) knowledge about how field is indexed.- Specified by:
constructQueryin interfaceQueryCreator- Returns:
- query if successfully parsed, or null.
-
constructQuery
public org.apache.lucene.search.Query constructQuery(Field field, IndexerField indexerField, java.lang.String query, SearchType type) throws org.apache.lucene.queryparser.classic.ParseException
- Throws:
org.apache.lucene.queryparser.classic.ParseException
-
legacyConstructQuery
public org.apache.lucene.search.Query legacyConstructQuery(java.lang.String field, java.lang.String query)
-
countTerms
protected int countTerms(IndexerField indexerField, java.lang.String query)
-
-