# Elasticsearch and Elastic.js

**URL:** <https://discuss.elastic.co/t/elasticsearch-and-elastic-js/12882>\
**Category:** Elasticsearch\
**Created:** [July 22, 2013, 6:20pm UTC](https://discuss.elastic.co/t/elasticsearch-and-elastic-js/12882 "2013-07-22T18:20:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jay\_S](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@Jay\_S](https://discuss.elastic.co/u/Jay_S)\
**Post date:** [July 22, 2013, 6:20pm UTC](https://discuss.elastic.co/t/elasticsearch-and-elastic-js/12882/1 "2013-07-22T18:20:37Z")

</div>

Hi,

i am currently using Elastic.js (Angular.js integration) to query  
Elasticsearch.

I have an Elasticsearch query that is as follows:

{  
"query" : {  
"range" : {  
"created\_at" : {  
"from" : "2013-07-21T03:55:32.000"  
}  
}  
}, "facets" : {  
"tag" : {  
"terms" : {  
"field" : "hashtag.text",  
"size" : 10  
}  
}  
}  
}

I am have a query that works without the data range filter, the query using  
Angular and Elastic.js is :

.query(ejs.QueryStringQuery($rootScope.globalVariable || '\*'))

```
            .facet(
                ejs.TermsFacet('tags')
          
                    .field('hashtag.text')

                    .size(50))

            .doSearch();

```

I have tried many combinations to add the date range filter.

Can anyone please give some ideas/clues on how I can do this?

Many thanks

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [July 22, 2013, 6:32pm UTC](https://discuss.elastic.co/t/elasticsearch-and-elastic-js/12882/2 "2013-07-22T18:32:47Z")

</div>

Use RangeQuery ([http://docs.fullscale.co/elasticjs/ejs.RangeQuery.html](http://docs.fullscale.co/elasticjs/ejs.RangeQuery.html)) not  
a QueryStringQuery.

.query(  
ejs.RangeQuery('created\_at').from('2013-07-21T03:55:32.000')  
)

.facet(  
ejs.TermsFacet('tags')  
.field('hashtag.text')  
.size(50)

)

.doSearch();

WIth elastic.js you piece together queries just like you would using the  
REST api.

Thanks,  
Matt Weber

On Mon, Jul 22, 2013 at 11:20 AM, Jay S [gplusacc0808@gmail.com](mailto:gplusacc0808@gmail.com) wrote:

> Hi,
> 
> i am currently using Elastic.js (Angular.js integration) to query  
> Elasticsearch.
> 
> I have an Elasticsearch query that is as follows:
> 
> {  
> "query" : {  
> "range" : {  
> "created\_at" : {  
> "from" : "2013-07-21T03:55:32.000"  
> }  
> }  
> }, "facets" : {  
> "tag" : {  
> "terms" : {  
> "field" : "hashtag.text",  
> "size" : 10  
> }  
> }  
> }  
> }
> 
> I am have a query that works without the data range filter, the query  
> using Angular and Elastic.js is :
> 
> .query(ejs.QueryStringQuery($rootScope.globalVariable || '\*'))
> 
> ```
> .facet(
> ejs.TermsFacet('tags')
> 
> .field('hashtag.text')
> 
> .size(50))
> 
> .doSearch();
> 
> ```
> 
> I have tried many combinations to add the date range filter.
> 
> Can anyone please give some ideas/clues on how I can do this?
> 
> Many thanks
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [July 22, 2013, 6:38pm UTC](https://discuss.elastic.co/t/elasticsearch-and-elastic-js/12882/3 "2013-07-22T18:38:34Z")

</div>

BTW, if you want to keep your query string and filter by the created date  
you would wrap it in a filtered query like this:

.query(  
ejs.FilteredQuery(  
ejs.QueryStringQuery($rootScope.globalVariable || '\*'),  
ejs.RangeFilter('created\_at').from('2013-07-21T03:55:32.000')  
)  
)

.facet(  
ejs.TermsFacet('tags')  
.field('hashtag.text')  
.size(50)  
)

.doSearch();

Hope this helped.

Thanks,  
Matt Weber

On Mon, Jul 22, 2013 at 11:32 AM, Matt Weber [matt.weber@gmail.com](mailto:matt.weber@gmail.com) wrote:

> Use RangeQuery ([http://docs.fullscale.co/elasticjs/ejs.RangeQuery.html](http://docs.fullscale.co/elasticjs/ejs.RangeQuery.html)) not  
> a QueryStringQuery.
> 
> .query(  
> ejs.RangeQuery('created\_at').from('2013-07-21T03:55:32.000')  
> )
> 
> .facet(  
> ejs.TermsFacet('tags')  
> .field('hashtag.text')  
> .size(50)
> 
> )
> 
> .doSearch();
> 
> WIth elastic.js you piece together queries just like you would using the  
> REST api.
> 
> Thanks,  
> Matt Weber
> 
> On Mon, Jul 22, 2013 at 11:20 AM, Jay S [gplusacc0808@gmail.com](mailto:gplusacc0808@gmail.com) wrote:
> 
> > Hi,
> > 
> > i am currently using Elastic.js (Angular.js integration) to query  
> > Elasticsearch.
> > 
> > I have an Elasticsearch query that is as follows:
> > 
> > {  
> > "query" : {  
> > "range" : {  
> > "created\_at" : {  
> > "from" : "2013-07-21T03:55:32.000"  
> > }  
> > }  
> > }, "facets" : {  
> > "tag" : {  
> > "terms" : {  
> > "field" : "hashtag.text",  
> > "size" : 10  
> > }  
> > }  
> > }  
> > }
> > 
> > I am have a query that works without the data range filter, the query  
> > using Angular and Elastic.js is :
> > 
> > .query(ejs.QueryStringQuery($rootScope.globalVariable || '\*'))
> > 
> > ```
> > .facet(
> > ejs.TermsFacet('tags')
> > 
> > .field('hashtag.text')
> > 
> > .size(50))
> > 
> > .doSearch();
> > 
> > ```
> > 
> > I have tried many combinations to add the date range filter.
> > 
> > Can anyone please give some ideas/clues on how I can do this?
> > 
> > Many thanks
> > 
> > --  
> > 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).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Jay\_S](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@Jay\_S](https://discuss.elastic.co/u/Jay_S)\
**Post date:** [July 22, 2013, 6:51pm UTC](https://discuss.elastic.co/t/elasticsearch-and-elastic-js/12882/4 "2013-07-22T18:51:40Z")

</div>

Hi Matt, it worked.

Thank you so much for your help. It is much appreciated.

Jay

On Monday, 22 July 2013 20:38:34 UTC+2, Matt Weber wrote:

> BTW, if you want to keep your query string and filter by the created date  
> you would wrap it in a filtered query like this:
> 
> .query(  
> ejs.FilteredQuery(  
> ejs.QueryStringQuery($rootScope.globalVariable || '\*'),  
> ejs.RangeFilter('created\_at').from('2013-07-21T03:55:32.000')  
> )  
> )
> 
> .facet(  
> ejs.TermsFacet('tags')  
> .field('hashtag.text')  
> .size(50)  
> )
> 
> .doSearch();
> 
> Hope this helped.
> 
> Thanks,  
> Matt Weber
> 
> On Mon, Jul 22, 2013 at 11:32 AM, Matt Weber \<[matt....@gmail.com](mailto:matt....@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Use RangeQuery ([The domain name Fullscale.co is for sale | Dan.com](http://docs.fullscale.co/elasticjs/ejs.RangeQuery.html)) not  
> > a QueryStringQuery.
> > 
> > .query(  
> > ejs.RangeQuery('created\_at').from('2013-07-21T03:55:32.000')  
> > )
> > 
> > .facet(  
> > ejs.TermsFacet('tags')  
> > .field('hashtag.text')  
> > .size(50)
> > 
> > )
> > 
> > .doSearch();
> > 
> > WIth elastic.js you piece together queries just like you would using the  
> > REST api.
> > 
> > Thanks,  
> > Matt Weber
> > 
> > On Mon, Jul 22, 2013 at 11:20 AM, Jay S \<[gplusa...@gmail.com](mailto:gplusa...@gmail.com)\<javascript:\>
> > 
> > > wrote:
> > 
> > > Hi,
> > > 
> > > i am currently using Elastic.js (Angular.js integration) to query  
> > > Elasticsearch.
> > > 
> > > I have an Elasticsearch query that is as follows:
> > > 
> > > {  
> > > "query" : {  
> > > "range" : {  
> > > "created\_at" : {  
> > > "from" : "2013-07-21T03:55:32.000"  
> > > }  
> > > }  
> > > }, "facets" : {  
> > > "tag" : {  
> > > "terms" : {  
> > > "field" : "hashtag.text",  
> > > "size" : 10  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > I am have a query that works without the data range filter, the query  
> > > using Angular and Elastic.js is :
> > > 
> > > .query(ejs.QueryStringQuery($rootScope.globalVariable || '\*'))
> > > 
> > > ```
> > > .facet(
> > > ejs.TermsFacet('tags')
> > >           
> > > .field('hashtag.text')
> > > 
> > > .size(50))
> > > 
> > > .doSearch();
> > > 
> > > ```
> > > 
> > > I have tried many combinations to add the date range filter.
> > > 
> > > Can anyone please give some ideas/clues on how I can do this?
> > > 
> > > Many thanks
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:25am UTC](https://discuss.elastic.co/t/elasticsearch-and-elastic-js/12882/5 "2017-07-06T02:25:08Z")

</div>


