jurismarches / luqum

A lucene query parser generating ElasticSearch queries and more !
Other
188 stars 40 forks source link

inverse ElasticsearchQueryBuilder #50

Closed elyase closed 4 years ago

elyase commented 4 years ago

Hi, is there a way to go in the opposite direction, i.e.: Elasticsearch -> Lucene Query DSL

alexgarel commented 4 years ago

Good question :-)

Right now in Luqum there is none, and it would be difficult to do it in a general manner, as Elasticsearch query DSL is far more rich than Lucene Query DSL !

But if you have a known subset you want to translate, you could try build a tree using components in tree.py and then simply using str() on it you would have it's representation. Use something like the visitor pattern on your ES query, and recursively build the tree.

elyase commented 4 years ago

great, thanks for the tips!

alexgarel commented 4 years ago

Good luck, I close the issue, so.

isra17 commented 3 years ago

@alexgarel I am looking to build something similar, is there any interest for a PR in Luqum?

alexgarel commented 3 years ago

@isra17, as I told in my post above, it is interesting if you have a known subset of ES query DSL that you can translate into Lucene.

If you do something general enough, eg. that can translate any ES query generated by luqum back into Lucene (or nearly any, or a superset), yes it could be a good proposal. If it's pluggable to generalize, it would be even more interesting.