use of org.parboiled.parserunners.RecoveringParseRunner in project ddf by codice.
the class OpenSearchQuery method addContextualFilter.
public void addContextualFilter(String searchTerm, String selectors) throws ParsingException {
String methodName = "addContextualFilter";
Filter filter = null;
KeywordFilterGenerator keywordFilterGenerator = new KeywordFilterGenerator(filterBuilder);
KeywordTextParser parser = Parboiled.createParser(KeywordTextParser.class);
// translate the search terms into an abstract syntax tree
ParsingResult<ASTNode> result = new RecoveringParseRunner(parser.inputPhrase()).run(searchTerm);
// make sure it's a good result before using it
if (result.matched && !result.hasErrors()) {
filter = generateContextualFilter(selectors, keywordFilterGenerator, result);
} else if (result.hasErrors()) {
throw new ParsingException("Unable to parse keyword search phrase. " + generateParsingError(result));
}
if (filter != null) {
filters.add(filter);
}
}
use of org.parboiled.parserunners.RecoveringParseRunner in project ddf by codice.
the class OpenSearchQuery method addContextualFilter.
public void addContextualFilter(String searchTerms, String selectors) throws ParsingException {
Filter filter = null;
KeywordFilterGenerator keywordFilterGenerator = new KeywordFilterGenerator(filterBuilder);
KeywordTextParser parser = Parboiled.createParser(KeywordTextParser.class);
// translate the search terms into an abstract syntax tree
ParsingResult<ASTNode> result = new RecoveringParseRunner(parser.inputPhrase()).run(searchTerms);
// make sure it's a good result before using it
if (result.matched && !result.hasErrors()) {
filter = generateContextualFilter(selectors, keywordFilterGenerator, result);
} else if (result.hasErrors()) {
throw new ParsingException("Unable to parse keyword search phrase. " + generateParsingError(result));
}
if (filter != null) {
filters.add(filter);
}
}
Aggregations