I am having trouble implementing a function that would apply composite fields to Lucene queries.
Instead of typing the lucene query:
title:"The Right Way" subject:"The Right Way"
I want users to be able to type:
all:"The Right Way"
Where all is composite field consisting of real fields title and subject. The function should generate a valid lucene query with constituents of a composite field expanded out.
String query = applyCompositeFields(String query, String compositeField, String[] subFields) {
} The supplied query may be any query according to the lucene query syntax (see: http://lucene.apache.org/core/old_versioned_docs/versions/3_0_0/queryparsersyntax.html#Range%20Searches)
For example:
all:[20020101 TO 20030101]
Should be expanded to:
title:[20020101 TO 20030101] subject:[20020101 TO 20030101]
Any ideas on how to do this neatly without breaking complex query inputs?
I've tried using the Lucene query object model, however, the field names cannot be set on the query elements, so its useless.