lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Atri Sharma <a...@apache.org>
Subject Re: Parameterized queries in Lucene
Date Mon, 21 Oct 2019 12:20:10 GMT
I am curious — what use case are you targeting to solve here?

In relational world, this is useful primarily due to the fact that prepared
statements eliminate the need for re planning the query, thus saving the
cost of iterating over a potentially large combinatorial space. However,
for Lucene, there isn’t so much of a concept of a query plan (yet). Some
queries try to achieve that (IndexOrDocValuesQuery for eg), but it is a far
cry from what relational databases expose.

Atri

On Mon, 21 Oct 2019 at 17:42, Stamatis Zampetakis <zabetak@gmail.com> wrote:

> Hi al
> 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
>
-- 
Regards,

Atri
Apache Concerted

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message