jurismarches / luqum

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

Add context as parameter to every EAbstractNode created in elasticsearch/visitor.py #104

Open alexgarel opened 3 weeks ago

alexgarel commented 3 weeks ago

I have a use case in search-a-licious where I wanted to add some parameter to EAbstractNode.

Note also, that as those parameters are query dependent and creating an ElasticsearchQueryBuilder instance is a bit time consuming, I want to do this at query generation time and not at class instantiation time.

It's currently difficult to do that without re-implementing part of the methods of the visitor.

It would be easier if:

  1. we enable adding an initial context in __call__ and visit methods
  2. we pass along this context each time we build an EAbstractNode

That way specific classes of EAbstractNode can tweak their result as much as they want with a minimal changes to ElasticsearchQueryBuilder.