Hi all,
In the world of relational databases and SQL, the existence of
parameterized queries (aka. PreparedStatement) offers many advantages in
terms of security and performance.
I guess everybody is familiar with the idea that you prepare a statement
and then you execute it multiple times by just changing certain parameters.
A simple use case for demonstrating the idea
is shown below:
Query q = ... // An arbitrary complex query with a part that has a single
parameter of type int
for (int i=0; i<100; i++) {
int paramValue = i;
q.visit(new ParameterSetter(paramValue));
TopDocs docs = searcher.search(q, 10);
}
Note that this is a very simplistic use case and does not correspond to the
reality where the construction and execution are not done side by side.
I already implemented something to satisfy use-cases like the one shown
above by introducing a new subclass of Query. However, I was wondering if
there is already a mechanism to compile and execute queries with parameters
in Lucene and I am just reinventing the wheel.
Feedback is much appreciated!
Best,
Stamatis