0
votes

I'm just wondering if there is a way to pass a pure dynamic Lucene syntax query including field:value pairs separated with boolean operators to the QueryParser. The query will be determined at runtime (possibly with a customized query builder). Since QueryParser needs a String(default field name) and an analyzer when its been instantiated, I don't know how to use the code.

Any help on that would be appreciative.

1

1 Answers

0
votes

I'm a bit confused. It sounds like your asking if you can use QueryParser to do exactly what it was designed to do...

For a bit of explanation, the analyzer finds terms within the text where necessary, StandardAnalyzer is an excellent starting point. The default field is just that, when you don't give a field for a term, it uses the one passed in here. The case of search terms without a specified field is covered in the query syntax docs.

Here's a fairly typical use of the QueryParser:

Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_43);
QueryParser parser = new QueryParser(Version.LUCENE_43, "myText", analyzer);
Query myQuery = parser.parse("My well-formed query");