public class FullTextSearchParser extends Object implements QueryParser
QueryParser
implementation that parses a full-text search expression. This grammar is based on the full-text search
grammar as defined by the JCR 2.0 specification.
The grammar for the full-text expression is taken from the JCR 2.0 specification, and is as follows:
FulltextSearch ::= Disjunct {Space 'OR' Space Disjunct} Disjunct ::= Term {Space Term} Term ::= ['-'] SimpleTerm SimpleTerm ::= Word | '"' Word {Space Word} '"' Word ::= NonSpaceChar {NonSpaceChar} Space ::= SpaceChar {SpaceChar} NonSpaceChar ::= Char - SpaceChar /* Any Char except SpaceChar */ SpaceChar ::= ' ' Char ::= /* Any character */
Modifier and Type | Class and Description |
---|---|
static class |
FullTextSearchParser.TermTokenizer
A basic
TokenStream.Tokenizer implementation that ignores whitespace but includes tokens for individual symbols, the period
('.'), single-quoted strings, double-quoted strings, whitespace-delimited words, and optionally comments. |
Modifier and Type | Field and Description |
---|---|
protected static List<? extends Column> |
FULL_TEXT_COLUMNS |
static String |
LANGUAGE |
Constructor and Description |
---|
FullTextSearchParser() |
Modifier and Type | Method and Description |
---|---|
String |
getLanguage()
Get the name of the language that this parser is able to understand.
|
FullTextSearch.Term |
parse(String fullTextSearchExpression)
Parse the full-text search criteria given in the supplied string.
|
FullTextSearch.Term |
parse(TokenStream tokens)
Parse the full-text search criteria from the supplied token stream.
|
protected FullTextSearch.Term |
parseDisjunctedTerms(TokenStream tokens) |
QueryCommand |
parseQuery(String query,
TypeSystem typeSystem)
Parse the supplied query from a string representation into a
QueryCommand . |
protected FullTextSearch.Term |
parseTerm(TokenStream tokens) |
protected String |
removeQuotes(String text)
Remove any leading and trailing single- or double-quotes from the supplied text.
|
public static final String LANGUAGE
public String getLanguage()
QueryParser
getLanguage
in interface QueryParser
public QueryCommand parseQuery(String query, TypeSystem typeSystem) throws InvalidQueryException
QueryParser
QueryCommand
.parseQuery
in interface QueryParser
query
- the query in string form; may not be nulltypeSystem
- the type system used by the query; may not be nullInvalidQueryException
- if the supplied query can be parsed but is invalidpublic FullTextSearch.Term parse(String fullTextSearchExpression)
fullTextSearchExpression
- the full-text search expression; may not be nullParsingException
- if there is an error parsing the supplied stringIllegalArgumentException
- if the expression is nullpublic FullTextSearch.Term parse(TokenStream tokens)
tokens
- the token stream containing the full-text search starting on the next tokenParsingException
- if there is an error parsing the supplied stringIllegalArgumentException
- if the token stream is nullprotected FullTextSearch.Term parseDisjunctedTerms(TokenStream tokens)
protected FullTextSearch.Term parseTerm(TokenStream tokens)
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.