# Elasticsearch Frontend webapp and boilerplate query code

**URL:** <https://discuss.elastic.co/t/elasticsearch-frontend-webapp-and-boilerplate-query-code/21456>\
**Category:** Elasticsearch\
**Created:** [January 2, 2015, 3:04pm UTC](https://discuss.elastic.co/t/elasticsearch-frontend-webapp-and-boilerplate-query-code/21456 "2015-01-02T15:04:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Bolis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomas_bolis/32/700_2.png) [@Thomas\_Bolis](https://discuss.elastic.co/u/Thomas_Bolis)\
**Post date:** [January 2, 2015, 3:04pm UTC](https://discuss.elastic.co/t/elasticsearch-frontend-webapp-and-boilerplate-query-code/21456/1 "2015-01-02T15:04:59Z")

</div>

Hi,

I wish everybody a happy new year, all the best for 2015, and in  
continuation of the great success of ES,

In our project we intend to create a simple webapp that will query  
elasticsearch for insights. We do not want to directly query elasticsearch  
for two reasons:

- security
- avoid boilerplate query code and to be able to decouple it

What is the best way to achieve that? We are currently evaluating building  
the frontend in python/django project. has anyone faced similiar task and  
is it possible to share some thoughts?

In other situations NGinX was a solution for security, but for avoiding  
having all the boilerplate query code in client side (e.g. in javascript)  
what is the most well established way?

Finally, there are cases were some caching may be needed to avoid hitting  
elasticsearch constantly for the same data, how is this tackled? We need to  
build our own module to do all these?

thank you in advance

Thomas

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7bdce45e-eff8-4f04-9a9b-f3256a9b28a9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7bdce45e-eff8-4f04-9a9b-f3256a9b28a9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [January 2, 2015, 3:10pm UTC](https://discuss.elastic.co/t/elasticsearch-frontend-webapp-and-boilerplate-query-code/21456/2 "2015-01-02T15:10:40Z")

</div>

Can you elaborate what you mean by "boilerplate query code"?

Jörg

On Fri, Jan 2, 2015 at 4:04 PM, Thomas [thomas.bolis@gmail.com](mailto:thomas.bolis@gmail.com) wrote:

> Hi,
> 
> I wish everybody a happy new year, all the best for 2015, and in  
> continuation of the great success of ES,
> 
> In our project we intend to create a simple webapp that will query  
> elasticsearch for insights. We do not want to directly query elasticsearch  
> for two reasons:
> 
> - security
> - avoid boilerplate query code and to be able to decouple it
> 
> What is the best way to achieve that? We are currently evaluating building  
> the frontend in python/django project. has anyone faced similiar task and  
> is it possible to share some thoughts?
> 
> In other situations NGinX was a solution for security, but for avoiding  
> having all the boilerplate query code in client side (e.g. in javascript)  
> what is the most well established way?
> 
> Finally, there are cases were some caching may be needed to avoid hitting  
> elasticsearch constantly for the same data, how is this tackled? We need to  
> build our own module to do all these?
> 
> thank you in advance
> 
> Thomas
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/7bdce45e-eff8-4f04-9a9b-f3256a9b28a9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7bdce45e-eff8-4f04-9a9b-f3256a9b28a9%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/7bdce45e-eff8-4f04-9a9b-f3256a9b28a9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/7bdce45e-eff8-4f04-9a9b-f3256a9b28a9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFuX\_D1v0eiMQ8Xnd6EBMu-t9U9pJYDC7VZppxv65UedA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFuX_D1v0eiMQ8Xnd6EBMu-t9U9pJYDC7VZppxv65UedA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Thomas\_Bolis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomas_bolis/32/700_2.png) [@Thomas\_Bolis](https://discuss.elastic.co/u/Thomas_Bolis)\
**Post date:** [January 2, 2015, 3:40pm UTC](https://discuss.elastic.co/t/elasticsearch-frontend-webapp-and-boilerplate-query-code/21456/3 "2015-01-02T15:40:35Z")

</div>

Yes,

Let's say that you wan to represent a pie graph with some short of  
aggregated data in it extracted from elasticsearch. Instead of writing the  
query in javascript or having it client side in the code we need something  
like a simple call of a get API for instance getMyPieData() from another  
service and get the data to represent that information.

If we let elasticsearch to do that we may want to use search templates:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

if we want to as well cache that query we may use elasticsearch query cache:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

That is what elasticsearch more or less provides for my use case afaik. My  
question is if there is something else that I can do to cache and "hide" my  
queries apart from the over-mentioned solutions which make me bound to  
elasticsearch(some separate module, technology etc. based on best  
practises), while in another case I might want to change elasticsearch with  
something else and still not affect my frontend code, or more important not  
to constantly hit elasticsearch for those data.

I'm trying to first verify that I will not reinvent the wheel and build my  
own solution

Thank you again

On Friday, 2 January 2015 17:04:59 UTC+2, Thomas wrote:

> Hi,
> 
> I wish everybody a happy new year, all the best for 2015, and in  
> continuation of the great success of ES,
> 
> In our project we intend to create a simple webapp that will query  
> elasticsearch for insights. We do not want to directly query elasticsearch  
> for two reasons:
> 
> - security
> - avoid boilerplate query code and to be able to decouple it
> 
> What is the best way to achieve that? We are currently evaluating building  
> the frontend in python/django project. has anyone faced similiar task and  
> is it possible to share some thoughts?
> 
> In other situations NGinX was a solution for security, but for avoiding  
> having all the boilerplate query code in client side (e.g. in javascript)  
> what is the most well established way?
> 
> Finally, there are cases were some caching may be needed to avoid hitting  
> elasticsearch constantly for the same data, how is this tackled? We need to  
> build our own module to do all these?
> 
> thank you in advance
> 
> Thomas

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2ba94df5-7f54-4ec3-87f5-7a038dd15ca7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2ba94df5-7f54-4ec3-87f5-7a038dd15ca7%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [January 2, 2015, 5:18pm UTC](https://discuss.elastic.co/t/elasticsearch-frontend-webapp-and-boilerplate-query-code/21456/4 "2015-01-02T17:18:19Z")

</div>

OK, you want to wrap a custom API around ES API.

Templates are on method to render strings into JSON but I think  
django-elasticsearch or the official python client is a better way to go if  
you must go with python/django

> **[GitHub - aparo/django-elasticsearch: Django ElasticSearch Backend](https://github.com/aparo/django-elasticsearch)**
>
> Django ElasticSearch Backend. Contribute to aparo/django-elasticsearch development by creating an account on GitHub.

> **[GitHub - elastic/elasticsearch-py: Official Python client for Elasticsearch](https://github.com/elastic/elasticsearch-py)**
>
> Official Python client for Elasticsearch. Contribute to elastic/elasticsearch-py development by creating an account on GitHub.

Caching is something which is not related to templates and might be  
overestimated, especially when all queires are different. I would suggest  
to add it later to your stack when everything is working ok.

Jörg

On Fri, Jan 2, 2015 at 4:40 PM, Thomas [thomas.bolis@gmail.com](mailto:thomas.bolis@gmail.com) wrote:

> Yes,
> 
> Let's say that you wan to represent a pie graph with some short of  
> aggregated data in it extracted from elasticsearch. Instead of writing the  
> query in javascript or having it client side in the code we need something  
> like a simple call of a get API for instance getMyPieData() from another  
> service and get the data to represent that information.
> 
> If we let elasticsearch to do that we may want to use search templates:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html#pre-registered-templates)
> 
> if we want to as well cache that query we may use elasticsearch query  
> cache:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-shard-query-cache.html#index-modules-shard-query-cache)
> 
> That is what elasticsearch more or less provides for my use case afaik. My  
> question is if there is something else that I can do to cache and "hide" my  
> queries apart from the over-mentioned solutions which make me bound to  
> elasticsearch(some separate module, technology etc. based on best  
> practises), while in another case I might want to change elasticsearch with  
> something else and still not affect my frontend code, or more important not  
> to constantly hit elasticsearch for those data.
> 
> I'm trying to first verify that I will not reinvent the wheel and build my  
> own solution
> 
> Thank you again
> 
> On Friday, 2 January 2015 17:04:59 UTC+2, Thomas wrote:
> 
> > Hi,
> > 
> > I wish everybody a happy new year, all the best for 2015, and in  
> > continuation of the great success of ES,
> > 
> > In our project we intend to create a simple webapp that will query  
> > elasticsearch for insights. We do not want to directly query elasticsearch  
> > for two reasons:
> > 
> > - security
> > - avoid boilerplate query code and to be able to decouple it
> > 
> > What is the best way to achieve that? We are currently evaluating  
> > building the frontend in python/django project. has anyone faced similiar  
> > task and is it possible to share some thoughts?
> > 
> > In other situations NGinX was a solution for security, but for avoiding  
> > having all the boilerplate query code in client side (e.g. in javascript)  
> > what is the most well established way?
> > 
> > Finally, there are cases were some caching may be needed to avoid hitting  
> > elasticsearch constantly for the same data, how is this tackled? We need to  
> > build our own module to do all these?
> > 
> > thank you in advance
> > 
> > Thomas
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/2ba94df5-7f54-4ec3-87f5-7a038dd15ca7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2ba94df5-7f54-4ec3-87f5-7a038dd15ca7%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/2ba94df5-7f54-4ec3-87f5-7a038dd15ca7%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/2ba94df5-7f54-4ec3-87f5-7a038dd15ca7%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHETLx%2B20PN5ui6AiL0PRV4Y%3D-Nq%2BjGkdvGvvheRrTkZg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHETLx%2B20PN5ui6AiL0PRV4Y%3D-Nq%2BjGkdvGvvheRrTkZg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:41am UTC](https://discuss.elastic.co/t/elasticsearch-frontend-webapp-and-boilerplate-query-code/21456/5 "2017-07-06T00:41:09Z")

</div>


