# DSL best practices

**URL:** https://discuss.elastic.co/t/dsl-best-practices/22033
**Category:** Elasticsearch
**Created:** [February 8, 2015, 2:49pm UTC](https://discuss.elastic.co/t/dsl-best-practices/22033 "2015-02-08T14:49:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![unlucio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/unlucio/32/841_2.png) [@unlucio](https://discuss.elastic.co/u/unlucio)
#### Post date: [February 8, 2015, 2:49pm UTC](https://discuss.elastic.co/t/dsl-best-practices/22033/1 "2015-02-08T14:49:29Z")

</div>

Hello everybody,  
I'm new to elastic search and trying to work my way with it since a couple  
of weeks.  
I'm using the node.js client  
([https://github.com/elasticsearch/elasticsearch-js](https://github.com/elasticsearch/elasticsearch-js)) and as I proceed in my  
journey I'm facing quite a bit of problems with the DSL as I'm often  
confused by it's syntax.  
What bothers me the most is I can't seems to be able to come up with simple  
and elegant queries.  
For example, while trying to use filters the only way I was able to make  
them work was with something like:

{  
"index": "",  
"body": {  
"query": {  
"filtered": {  
"query": {  
"query\_string": {  
"query": ""  
}  
},  
"filter": {  
"and": {  
"filters": [  
{  
"terms": {  
"\<someProperty.someKey\>": [  
""  
]  
}  
},  
{  
"terms": {  
"\<someOtherProperty.someKey\>": [  
""  
]  
}  
}  
]  
}  
}  
}  
}  
}  
}

It was kind of hard to produce and harder to understand the next day.  
Do you have any suggestion on how to better approach the DSL?

thank you, best regards  
lucio

--  
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/f0b73504-3979-4bdf-aefd-482dd33aa809%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f0b73504-3979-4bdf-aefd-482dd33aa809%40googlegroups.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:34am UTC](https://discuss.elastic.co/t/dsl-best-practices/22033/2 "2017-07-06T00:34:18Z")

</div>


