Search in sources :

Example 1 with AccumuloSyntaxParser

use of datawave.query.language.parser.lucene.AccumuloSyntaxParser in project datawave by NationalSecurityAgency.

the class LuceneToJexlQueryParser method convertToJexlNode.

public JexlNode convertToJexlNode(String query) throws ParseException {
    // replace open smart quote 147
    query = query.replaceAll("\\u0093", "\"");
    // replace close smart quote 148
    query = query.replaceAll("\\u0094", "\"");
    // replace open left double quote
    query = query.replaceAll("\\u201c", "\"");
    // replace close right double quote
    query = query.replaceAll("\\u201d", "\"");
    JexlNode parsedQuery = null;
    try {
        Locale.setDefault(Locale.US);
        AccumuloSyntaxParser syntaxParser = new AccumuloSyntaxParser();
        syntaxParser.enable_tracing();
        QueryNodeProcessor processor = getQueryNodeProcessor();
        QueryBuilder builder = new JexlTreeBuilder(allowedFunctions);
        org.apache.lucene.queryparser.flexible.core.nodes.QueryNode queryTree = syntaxParser.parse(query, "");
        queryTree = processor.process(queryTree);
        parsedQuery = (JexlNode) builder.build(queryTree);
    } catch (Exception e) {
        throw new ParseException(e);
    }
    return parsedQuery;
}
Also used : JexlTreeBuilder(datawave.query.language.builder.jexl.JexlTreeBuilder) AccumuloSyntaxParser(datawave.query.language.parser.lucene.AccumuloSyntaxParser) QueryBuilder(org.apache.lucene.queryparser.flexible.core.builders.QueryBuilder) ParseException(datawave.query.language.parser.ParseException) QueryNodeProcessor(org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessor) ParseException(datawave.query.language.parser.ParseException)

Aggregations

JexlTreeBuilder (datawave.query.language.builder.jexl.JexlTreeBuilder)1 ParseException (datawave.query.language.parser.ParseException)1 AccumuloSyntaxParser (datawave.query.language.parser.lucene.AccumuloSyntaxParser)1 QueryBuilder (org.apache.lucene.queryparser.flexible.core.builders.QueryBuilder)1 QueryNodeProcessor (org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessor)1