Java API: Reconstruct QueryBuilder object from query String/byte array

Hi!

I have a library of ElasticSearch queries, which I need to use as
building blocks to construct other, larger, queries. This works just
fine as long as I retain Java TermQueryBuilder objects (et cetera),
but since I need to store the library, I have to convert them to byte
arrays (which I use to construct Strings, as my database won't store
arrays); I can't find another way to do store them permanently, as
query builders aren't directly serializable. It is important to keep
the ability to use the stored queries as clauses etc., and this I
can't seem to find a way to do.

Is there a way to re-parse a query byte array (or String) into a query
builder object? I realize I could generate the JSON for the big
queries myself, but I need quite a few types of queries and that would
mean quite a lot of effort to essentially duplicate functionality that
ES already appears to have (after all, it does parse queries that i
curl to it...)

Thanks
Felix

The way ES is structured, then the parsing phase of queries is at a "different level" then the generation part (it is associated with a concrete index, to allow for plugins adding custom query parser).

On Friday, June 10, 2011 at 1:56 PM, Felix wrote:

Hi!

I have a library of Elasticsearch queries, which I need to use as
building blocks to construct other, larger, queries. This works just
fine as long as I retain Java TermQueryBuilder objects (et cetera),
but since I need to store the library, I have to convert them to byte
arrays (which I use to construct Strings, as my database won't store
arrays); I can't find another way to do store them permanently, as
query builders aren't directly serializable. It is important to keep
the ability to use the stored queries as clauses etc., and this I
can't seem to find a way to do.

Is there a way to re-parse a query byte array (or String) into a query
builder object? I realize I could generate the JSON for the big
queries myself, but I need quite a few types of queries and that would
mean quite a lot of effort to essentially duplicate functionality that
ES already appears to have (after all, it does parse queries that i
curl to it...)

Thanks
Felix