# Search\_query

**URL:** <https://discuss.elastic.co/t/search-query/4682>\
**Category:** Elasticsearch\
**Created:** [June 22, 2011, 8:39am UTC](https://discuss.elastic.co/t/search-query/4682 "2011-06-22T08:39:19Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Chris\_Berkhout](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_berkhout/32/3058_2.png) [@Chris\_Berkhout](https://discuss.elastic.co/u/Chris_Berkhout)\
**Post date:** [June 29, 2011, 10:11am UTC](https://discuss.elastic.co/t/search-query/4682/21 "2011-06-29T10:11:16Z")

</div>

Sandeep,

The docs are working for me at:

> **[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.

> **[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.

> **[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.

> **[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.

The first problem is that your query isn't valid JSON (a JSON object  
can't have two properties with the same name).  
Try indenting it clearly so you can see the JSON error, then refer to  
the docs for the correct query syntax.

Cheers,  
Chris

On Wed, Jun 29, 2011 at 5:50 PM, sandeep tiwari [sandeep15mca@gmail.com](mailto:sandeep15mca@gmail.com) wrote:

> On Fri, Jun 24, 2011 at 4:30 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)  
> wrote:
> 
> > On Fri, 2011-06-24 at 16:05 +0530, sandeep tiwari wrote:
> > 
> > > Sir!  
> > > After executing the query there is some exception please check  
> > > query-
> > 
> > Sandeep - please read the docs. your syntax error is pretty obvious.
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/and-filter.html)  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/or-filter.html)  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/not-filter.html)
> 
> Sir!  
> I try to open docs on [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/docs) but its give 404  
> code error while speed is to good I request to you please guide me where  
> syntax error in-  
> curl -XGET '[http://127.0.0.1:9200/mydb2/mytype2/\_search?pretty=true](http://127.0.0.1:9200/mydb2/mytype2/_search?pretty=true)' -d '  
> '{  
> "filtered":{  
> "query":{  
> "constant\_score" : {  
> "filter" : {"and":[{  
> "range" : {  
> "date" : {  
> "lte" : "2011-09-01",  
> "gte" : "2011-09-10"  
> }  
> }  
> }],  
> "and":[{"range" : {  
> "date" : {  
> "lte" : "2011-10-07",  
> "gte" : "2011-10-17"  
> }  
> }  
> }]  
> }  
> }  
> }  
> }  
> }'  
> because is is generated exception.  
> thanks
> 
> > clint

---

<div class="post-metadata">

**Author:** ![sandeep15mca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandeep15mca/32/3178_2.png) [@sandeep15mca](https://discuss.elastic.co/u/sandeep15mca)\
**Post date:** [June 29, 2011, 1:12pm UTC](https://discuss.elastic.co/t/search-query/4682/22 "2011-06-29T13:12:29Z")

</div>

Sir!  
My problem is that to find out details of between two different dates  
-for which we apply query which I have send u previous request please send  
me query which fulfill my requirements.  
because last three days I have been my best but couldn't got success.

```
                                      thanks.

```

On Wed, Jun 29, 2011 at 3:41 PM, Chris Berkhout [chrisberkhout@gmail.com](mailto:chrisberkhout@gmail.com)wrote:

> Sandeep,
> 
> The docs are working for me at:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/)  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/and-filter.html)  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/or-filter.html)  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/not-filter.html)
> 
> The first problem is that your query isn't valid JSON (a JSON object  
> can't have two properties with the same name).  
> Try indenting it clearly so you can see the JSON error, then refer to  
> the docs for the correct query syntax.
> 
> Cheers,  
> Chris
> 
> On Wed, Jun 29, 2011 at 5:50 PM, sandeep tiwari [sandeep15mca@gmail.com](mailto:sandeep15mca@gmail.com)  
> wrote:
> 
> > On Fri, Jun 24, 2011 at 4:30 PM, Clinton Gormley \<  
> > [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)\>  
> > wrote:
> > 
> > > On Fri, 2011-06-24 at 16:05 +0530, sandeep tiwari wrote:
> > > 
> > > > Sir!  
> > > > After executing the query there is some exception please check  
> > > > query-
> > > 
> > > Sandeep - please read the docs. your syntax error is pretty obvious.
> > > 
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/and-filter.html)  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/or-filter.html)  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/not-filter.html)
> > 
> > Sir!  
> > I try to open docs on [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/docs) but its give  
> > 404  
> > code error while speed is to good I request to you please guide me where  
> > syntax error in-  
> > curl -XGET '[http://127.0.0.1:9200/mydb2/mytype2/\_search?pretty=true](http://127.0.0.1:9200/mydb2/mytype2/_search?pretty=true)' -d  
> > '  
> > '{  
> > "filtered":{  
> > "query":{  
> > "constant\_score" : {  
> > "filter" : {"and":[{  
> > "range" : {  
> > "date" : {  
> > "lte" : "2011-09-01",  
> > "gte" : "2011-09-10"  
> > }  
> > }  
> > }],  
> > "and":[{"range" : {  
> > "date" : {  
> > "lte" : "2011-10-07",  
> > "gte" : "2011-10-17"  
> > }  
> > }  
> > }]  
> > }  
> > }  
> > }  
> > }  
> > }'  
> > because is is generated exception.  
> > thanks
> > 
> > > clint

---

<div class="post-metadata">

**Author:** ![sandeep15mca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandeep15mca/32/3178_2.png) [@sandeep15mca](https://discuss.elastic.co/u/sandeep15mca)\
**Post date:** [June 30, 2011, 6:16am UTC](https://discuss.elastic.co/t/search-query/4682/23 "2011-06-30T06:16:54Z")

</div>

Sir!  
I am facing a problem regarding previous query which I have send  
yesterday and  
I want to apply facet in that query for find the valuable result my  
query is bellow which is not work properly-  
$ curl -XGET '[http://192.168.1.100:9200/mydb2/mytype2/\_search?pretty=true](http://192.168.1.100:9200/mydb2/mytype2/_search?pretty=true)'  
-d  
'{  
"filtered":{  
"query":{  
"constant\_score" : {  
"filter" : {"or":[{  
"range" : {  
"date" : {  
"lte" : "2011-09-01",  
"gte" : "2011-09-10"

```
          }

```

},"facet":{"range":{"date":{"lte":2011-10-17"","gte":2011-10-07""}}}

```
    }]
 }
}
}'

```

On Wed, Jun 29, 2011 at 6:42 PM, sandeep tiwari [sandeep15mca@gmail.com](mailto:sandeep15mca@gmail.com)wrote:

> Sir!  
> My problem is that to find out details of between two different dates  
> -for which we apply query which I have send u previous request please send  
> me query which fulfill my requirements.  
> because last three days I have been my best but couldn't got success.
> 
> ```
> thanks.
> 
> ```
> 
> On Wed, Jun 29, 2011 at 3:41 PM, Chris Berkhout [chrisberkhout@gmail.com](mailto:chrisberkhout@gmail.com)wrote:
> 
> > Sandeep,
> > 
> > The docs are working for me at:  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/)  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/and-filter.html)  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/or-filter.html)  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/not-filter.html)
> > 
> > The first problem is that your query isn't valid JSON (a JSON object  
> > can't have two properties with the same name).  
> > Try indenting it clearly so you can see the JSON error, then refer to  
> > the docs for the correct query syntax.
> > 
> > Cheers,  
> > Chris
> > 
> > On Wed, Jun 29, 2011 at 5:50 PM, sandeep tiwari [sandeep15mca@gmail.com](mailto:sandeep15mca@gmail.com)  
> > wrote:
> > 
> > > On Fri, Jun 24, 2011 at 4:30 PM, Clinton Gormley \<  
> > > [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)\>  
> > > wrote:
> > > 
> > > > On Fri, 2011-06-24 at 16:05 +0530, sandeep tiwari wrote:
> > > > 
> > > > > Sir!  
> > > > > After executing the query there is some exception please check  
> > > > > query-
> > > > 
> > > > Sandeep - please read the docs. your syntax error is pretty obvious.
> > > > 
> > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/and-filter.html)  
> > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/or-filter.html)  
> > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/not-filter.html)
> > > 
> > > Sir!  
> > > I try to open docs on [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/docs) but its give  
> > > 404  
> > > code error while speed is to good I request to you please guide me where  
> > > syntax error in-  
> > > curl -XGET '[http://127.0.0.1:9200/mydb2/mytype2/\_search?pretty=true](http://127.0.0.1:9200/mydb2/mytype2/_search?pretty=true)'  
> > > -d '  
> > > '{  
> > > "filtered":{  
> > > "query":{  
> > > "constant\_score" : {  
> > > "filter" : {"and":[{  
> > > "range" : {  
> > > "date" : {  
> > > "lte" : "2011-09-01",  
> > > "gte" : "2011-09-10"  
> > > }  
> > > }  
> > > }],  
> > > "and":[{"range" : {  
> > > "date" : {  
> > > "lte" : "2011-10-07",  
> > > "gte" : "2011-10-17"  
> > > }  
> > > }  
> > > }]  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }'  
> > > because is is generated exception.  
> > > thanks
> > > 
> > > > clint

---

<div class="post-metadata">

**Author:** ![sandeep15mca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandeep15mca/32/3178_2.png) [@sandeep15mca](https://discuss.elastic.co/u/sandeep15mca)\
**Post date:** [June 30, 2011, 7:16am UTC](https://discuss.elastic.co/t/search-query/4682/24 "2011-06-30T07:16:47Z")

</div>

Sir!  
I am facing a problem regarding previous query which I have send  
yesterday and  
I want to apply facet in that query for find the valuable result my  
query is bellow which is not work properly-  
$ curl -XGET '[http://192.168.1.100:9200/mydb2/mytype2/\_search?pretty=true](http://192.168.1.100:9200/mydb2/mytype2/_search?pretty=true)'  
-d  
'{  
"filtered":{  
"query":{  
"constant\_score" : {  
"filter" : {"or":[{  
"range" : {  
"date" : {  
"lte" : "2011-09-01",  
"gte" : "2011-09-10"

```
          }

```

},"facet":{"range":{"date":{"lte":2011-10-17"","gte":2011-10-07""}}}

```
    }]
 }
}

```

}'  
and another problem is that docs is nnot open give authentication  
error.please help me

```
                                                       thanks

```

On Wed, Jun 22, 2011 at 3:02 PM, Lukáš Vlček [lukas.vlcek@gmail.com](mailto:lukas.vlcek@gmail.com) wrote:

> Hi,
> 
> can you give some example of the output you want to get from the search  
> engine?
> 
> Regards,  
> Lukas
> 
> On Wed, Jun 22, 2011 at 11:13 AM, sandeep tiwari [sandeep15mca@gmail.com](mailto:sandeep15mca@gmail.com)wrote:
> 
> > Sir!  
> > I want to know how use group by date in my Elasticsearch query.
> > 
> > On Wed, Jun 22, 2011 at 2:39 PM, Lukáš Vlček [lukas.vlcek@gmail.com](mailto:lukas.vlcek@gmail.com)wrote:
> > 
> > > Hi,
> > > 
> > > On Wed, Jun 22, 2011 at 10:39 AM, sandeep tiwari \<[sandeep15mca@gmail.com](mailto:sandeep15mca@gmail.com)
> > > 
> > > > wrote:
> > > 
> > > > Hi!  
> > > > if anybody have been used groupby query in Elasticsearch.Please  
> > > > reply me.
> > > > 
> > > > ```
> > > > Your Thankfully
> > > > 
> > > > Sandeep Kumar Tiwari
> > > > 
> > > > ```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 30, 2011, 9:00am UTC](https://discuss.elastic.co/t/search-query/4682/25 "2011-06-30T09:00:34Z")

</div>

I suggest you parse your JSon documents before sending them to ES  
"facet":{"range":{"date":{"lte":2011-10-17"","gte":2011-10-07""}}}

should be something like  
"facet":{"range":{"date":{"lte":"2011-10-17","gte":"2011-10-07"}}}

You can use the great mobz EShead project : [https://github.com/mobz/elasticsearch-head](https://github.com/mobz/elasticsearch-head)

David.

---

<div class="post-metadata">

**Author:** ![sandeep15mca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandeep15mca/32/3178_2.png) [@sandeep15mca](https://discuss.elastic.co/u/sandeep15mca)\
**Post date:** [June 30, 2011, 9:28am UTC](https://discuss.elastic.co/t/search-query/4682/26 "2011-06-30T09:28:04Z")

</div>

Sir!  
After execute bellow query follwing exception/error comes out,My  
excpected result is -  
yyyy-mm-dd-all information  
yyyy-mm-dd-allinformation  
till last date please help me ASAP.  
$ curl -XGET '[http://192.168.1.100:9200/mydb2/mytype2/\_search?pretty=true](http://192.168.1.100:9200/mydb2/mytype2/_search?pretty=true)'  
-d  
'{  
"filtered":{  
"query":{  
"constant\_score" : {  
"filter" : {"or":[{  
"range" : {  
"date" : {  
"lte" : "2011-09-10",  
"gte" : "2011-09-01"

```
          }

```

},"facet":{"range":{"date":{"lte":2011-10-17","gte":"2011-10-07"}}}  
}]  
}  
}  
}'  
{  
"error" : "SearchPhaseExecutionException[Failed to execute phase [query],  
tota  
l failure; shardFailures {[JLoAsYWIQvS87JhMKhBr5Q][mydb2][0]:  
SearchParseExcepti  
on[[mydb2][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  
"  
filtered":{\n "query":{\n "constant\_score" : {\n "filter"  
: {  
"or":[{\n "range" : {\n "date" : {\n  
"lte" : "2011-09-10",\n "gte" : "2011-09-01"\n\n  
}\n  
},"facet":{"range":{"date":{"lte":2011-10-17","g  
te":"2011-10-07"}}}\n }]\n }\n }\n }]]]; nested:  
SearchParse  
Exception[[mydb2][0]: from[-1],size[-1]: Parse Failure [No parser for  
element [f  
iltered]]]; }{[JLoAsYWIQvS87JhMKhBr5Q][mydb2][1]:  
SearchParseException[[mydb2][1  
]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  
"filtered":{  
\n "query":{\n "constant\_score" : {\n "filter" :  
{"or":[{\n  
"range" : {\n "date" : {\n  
"lte" :  
"2011-09-10",\n "gte" : "2011-09-01"\n\n  
}\n

},"facet":{"range":{"date":{"lte":2011-10-17","gte":"2011-  
10-07"}}}\n }]\n }\n }\n }]]]; nested:  
SearchParseException[[m  
ydb2][1]: from[-1],size[-1]: Parse Failure [No parser for element  
[filtered]]];  
}{[JLoAsYWIQvS87JhMKhBr5Q][mydb2][2]: SearchParseException[[mydb2][2]:  
from[-1],  
size[-1]: Parse Failure [Failed to parse source [{\n "filtered":{\n  
"query  
":{\n "constant\_score" : {\n "filter" : {"or":[{\n  
"  
range" : {\n "date" : {\n "lte" :  
"2011-09-10  
",\n "gte" : "2011-09-01"\n\n }\n  
},  
"facet":{"range":{"date":{"lte":2011-10-17","gte":"2011-10-07"}}}\n  
}]\n }\n }\n }]]]; nested:  
SearchParseException[[mydb2][2]: fr  
om[-1],size[-1]: Parse Failure [No parser for element [filtered]]];  
}{[JLoAsYWIQ  
vS87JhMKhBr5Q][mydb2][3]: SearchParseException[[mydb2][3]:  
from[-1],size[-1]: Pa  
rse Failure [Failed to parse source [{\n "filtered":{\n "query":{\n  
"  
constant\_score" : {\n "filter" : {"or":[{\n "range"  
: {  
n "date" : {\n "lte" : "2011-09-10",\n  
"gte" : "2011-09-01"\n\n }\n  
},"facet":{  
"range":{"date":{"lte":2011-10-17","gte":"2011-10-07"}}}\n  
}]\n  
}\n }\n }]]]; nested: SearchParseException[[mydb2][3]:  
from[-1],size[  
-1]: Parse Failure [No parser for element [filtered]]];  
}{[JLoAsYWIQvS87JhMKhBr5  
Q][mydb2][4]: SearchParseException[[mydb2][4]: from[-1],size[-1]: Parse  
Failure  
[Failed to parse source [{\n "filtered":{\n "query":{\n  
"constant\_sco  
re" : {\n "filter" : {"or":[{\n "range" : {\n  
"date" : {\n "lte" : "2011-09-10",\n  
"  
gte" : "2011-09-01"\n\n }\n  
},"facet":{"range":{"  
date":{"lte":2011-10-17","gte":"2011-10-07"}}}\n }]\n }\n  
}\n }]]]; nested: SearchParseException[[mydb2][4]: from[-1],size[-1]:  
Parse F  
ailure [No parser for element [filtered]]]; }]",  
"status" : 500  
}

On Thu, Jun 30, 2011 at 2:30 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> I suggest you parse your JSon documents before sending them to ES  
> "facet":{"range":{"date":{"lte":_2011-10-17""_,"gte":_2011-10-07""_}}}
> 
> should be something like  
> "facet":{"range":{"date":{"lte":_"2011-10-17"_,"gte":_"2011-10-07"_}}}
> 
> You can use the great mobz EShead project :  
> [GitHub - mobz/elasticsearch-head: A web front end for an elastic search cluster](https://github.com/mobz/elasticsearch-head)
> 
> David.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 30, 2011, 9:41am UTC](https://discuss.elastic.co/t/search-query/4682/27 "2011-06-30T09:41:37Z")

</div>

Reading the doc here : [http://www.elasticsearch.org/guide/reference/query-dsl/filtered-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/filtered-query.html) it seems that Filtered Query is "a query that applies a filter to the results of another query."

There is no query in your search call.

Try to add a "match\_all" before filtering anything.  
[http://www.elasticsearch.org/guide/reference/query-dsl/match-all-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/match-all-query.html)

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 30, 2011, 9:43am UTC](https://discuss.elastic.co/t/search-query/4682/28 "2011-06-30T09:43:15Z")

</div>

Sorry bad answer. Forget it !

---

<div class="post-metadata">

**Author:** ![Stefan\_Matheis](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Stefan\_Matheis](https://discuss.elastic.co/u/Stefan_Matheis)\
**Post date:** [June 30, 2011, 9:51am UTC](https://discuss.elastic.co/t/search-query/4682/29 "2011-06-30T09:51:13Z")

</div>

On Thu, Jun 30, 2011 at 11:28 AM, sandeep tiwari [sandeep15mca@gmail.com](mailto:sandeep15mca@gmail.com)wrote:

> },"facet":{"range":{"date":{"lte":2011-10-17","gte":"2011-10-07"}}}

You're missing the quotes .. "lte":"2011-10-17" ..

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [June 30, 2011, 9:59am UTC](https://discuss.elastic.co/t/search-query/4682/30 "2011-06-30T09:59:59Z")

</div>

On Thu, 2011-06-30 at 11:00 +0200, David Pilato wrote:

> I suggest you parse your JSon documents before sending them to ES  
> "facet":{"range":{"date":{"lte":2011-10-17"","gte":2011-10-07""}}}
> 
> should be something like  
> "facet":{"range":{"date":{"lte":"2011-10-17","gte":"2011-10-07"}}}

Actually, range facets only support to/from at the moment, not  
gt/gte/lt/lte

> **[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.

Clint

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [June 30, 2011, 10:09am UTC](https://discuss.elastic.co/t/search-query/4682/31 "2011-06-30T10:09:30Z")

</div>

Hi Sandeep

> ```
> I want to apply facet in that query for find the valuable result
> 
> ```
> 
> my query is bellow which is not work properly-  
> $ curl -XGET  
> '[http://192.168.1.100:9200/mydb2/mytype2/\_search?pretty=true](http://192.168.1.100:9200/mydb2/mytype2/_search?pretty=true)' -d  
> '{  
> "filtered":{

Why do you have "filtered" on the line above?

The structure of a query is always:

[http://localhost:9200/index/type/\_search?pretty=true](http://localhost:9200/index/type/_search?pretty=true)' -d '  
{ query: {.....} }  
'

The "query" must be at the top level. Always.

Then you have 3 choices:

1. a query clause eg { text: { title: "john smith" }}
2. a filter clause eg { term: {status: "active" }}
3. a query and filter clause eg both of the above

If you have just a query, then you can add it directly:

{ query: {  
text: { title: "john smith" }  
}}

If you have just a filter, then you should wrap it in a constant\_score  
query:

{ query: {  
constant\_score: {  
filter: {  
term: { status: "active" }  
}  
}  
}}

If you want to combine a query and a filter, then you should wrap them  
in a filtered query:

{ query: {  
filtered: {  
query: { text: { title: "john smith" }},  
filter: { term: { status: "active" }}  
}  
}}

clint

---

<div class="post-metadata">

**Author:** ![sandeep15mca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandeep15mca/32/3178_2.png) [@sandeep15mca](https://discuss.elastic.co/u/sandeep15mca)\
**Post date:** [June 30, 2011, 10:12am UTC](https://discuss.elastic.co/t/search-query/4682/32 "2011-06-30T10:12:13Z")

</div>

thanks lot Sir.......

On Thu, Jun 30, 2011 at 3:39 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:

> Hi Sandeep
> 
> > ```
> > I want to apply facet in that query for find the valuable result
> > 
> > ```
> > 
> > my query is bellow which is not work properly-  
> > $ curl -XGET  
> > '[http://192.168.1.100:9200/mydb2/mytype2/\_search?pretty=true](http://192.168.1.100:9200/mydb2/mytype2/_search?pretty=true)' -d  
> > '{  
> > "filtered":{
> 
> Why do you have "filtered" on the line above?
> 
> The structure of a query is always:
> 
> [http://localhost:9200/index/type/\_search?pretty=true](http://localhost:9200/index/type/_search?pretty=true)' -d '  
> { query: {.....} }  
> '
> 
> The "query" must be at the top level. Always.
> 
> Then you have 3 choices:
> 
> 1. a query clause eg { text: { title: "john smith" }}
> 2. a filter clause eg { term: {status: "active" }}
> 3. a query and filter clause eg both of the above
> 
> If you have just a query, then you can add it directly:
> 
> { query: {  
> text: { title: "john smith" }  
> }}
> 
> If you have just a filter, then you should wrap it in a constant\_score  
> query:
> 
> { query: {  
> constant\_score: {  
> filter: {  
> term: { status: "active" }  
> }  
> }  
> }}
> 
> If you want to combine a query and a filter, then you should wrap them  
> in a filtered query:
> 
> { query: {  
> filtered: {  
> query: { text: { title: "john smith" }},  
> filter: { term: { status: "active" }}  
> }  
> }}
> 
> clint

---

<div class="post-metadata">

**Author:** ![sandeep15mca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandeep15mca/32/3178_2.png) [@sandeep15mca](https://discuss.elastic.co/u/sandeep15mca)\
**Post date:** [June 30, 2011, 10:21am UTC](https://discuss.elastic.co/t/search-query/4682/33 "2011-06-30T10:21:19Z")

</div>

Sir!  
curl -XGET '  
[http://192.168.1.100:9200/mydb2/mytype2/\_search?pretty=true](http://192.168.1.100:9200/mydb2/mytype2/_search?pretty=true)' -d  
'{  
"query":{  
"constant\_score" : {  
"filter" : {"or":[{  
"range" : {  
"date" : {  
"to" : "2011-09-10",  
"from" : "2011-09-01"

```
         }

```

},"facet":{"range":{"date":{"to":"2011-10-17","from":"2011-10-07"}}}

```
   }]

```

}}  
sorry sir inconvenience but it is not working even please help me  
On Thu, Jun 30, 2011 at 3:42 PM, sandeep tiwari [sandeep15mca@gmail.com](mailto:sandeep15mca@gmail.com)wrote:

> thanks lot Sir.......
> 
> On Thu, Jun 30, 2011 at 3:39 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:
> 
> > Hi Sandeep
> > 
> > > ```
> > > I want to apply facet in that query for find the valuable result
> > > 
> > > ```
> > > 
> > > my query is bellow which is not work properly-  
> > > $ curl -XGET  
> > > '[http://192.168.1.100:9200/mydb2/mytype2/\_search?pretty=true](http://192.168.1.100:9200/mydb2/mytype2/_search?pretty=true)' -d  
> > > '{  
> > > "filtered":{
> > 
> > Why do you have "filtered" on the line above?
> > 
> > The structure of a query is always:
> > 
> > [http://localhost:9200/index/type/\_search?pretty=true](http://localhost:9200/index/type/_search?pretty=true)' -d '  
> > { query: {.....} }  
> > '
> > 
> > The "query" must be at the top level. Always.
> > 
> > Then you have 3 choices:
> > 
> > 1. a query clause eg { text: { title: "john smith" }}
> > 2. a filter clause eg { term: {status: "active" }}
> > 3. a query and filter clause eg both of the above
> > 
> > If you have just a query, then you can add it directly:
> > 
> > { query: {  
> > text: { title: "john smith" }  
> > }}
> > 
> > If you have just a filter, then you should wrap it in a constant\_score  
> > query:
> > 
> > { query: {  
> > constant\_score: {  
> > filter: {  
> > term: { status: "active" }  
> > }  
> > }  
> > }}
> > 
> > If you want to combine a query and a filter, then you should wrap them  
> > in a filtered query:
> > 
> > { query: {  
> > filtered: {  
> > query: { text: { title: "john smith" }},  
> > filter: { term: { status: "active" }}  
> > }  
> > }}
> > 
> > clint

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [June 30, 2011, 10:27am UTC](https://discuss.elastic.co/t/search-query/4682/34 "2011-06-30T10:27:08Z")

</div>

> sorry sir inconvenience but it is not working even please help me

"it is not working" is not useful

Sandeep you're really going to have to learn to understand what you're  
doing. You can't just copy and paste this stuff.

Check the syntax of your query. (Clue: it is incorrect).

Break it down into small parts - get those parts working, then add  
bigger parts.

clint

---

<div class="post-metadata">

**Author:** ![sandeep15mca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandeep15mca/32/3178_2.png) [@sandeep15mca](https://discuss.elastic.co/u/sandeep15mca)\
**Post date:** [June 30, 2011, 10:31am UTC](https://discuss.elastic.co/t/search-query/4682/35 "2011-06-30T10:31:37Z")

</div>

Thanks Sir!

On Thu, Jun 30, 2011 at 3:51 PM, sandeep tiwari [sandeep15mca@gmail.com](mailto:sandeep15mca@gmail.com)wrote:

> Sir!  
> curl -XGET '  
> [http://192.168.1.100:9200/mydb2/mytype2/\_search?pretty=true](http://192.168.1.100:9200/mydb2/mytype2/_search?pretty=true)' -d  
> '{  
> "query":{  
> "constant\_score" : {  
> "filter" : {"or":[{  
> "range" : {  
> "date" : {  
> "to" : "2011-09-10",  
> "from" : "2011-09-01"
> 
> ```
> }
> 
> ```
> 
> },"facet":{"range":{"date":{"to":"2011-10-17","from":"2011-10-07"}}}
> 
> ```
> }]
> 
> ```
> 
> }}  
> sorry sir inconvenience but it is not working even please help me
> 
> On Thu, Jun 30, 2011 at 3:42 PM, sandeep tiwari [sandeep15mca@gmail.com](mailto:sandeep15mca@gmail.com)wrote:
> 
> > thanks lot Sir.......
> > 
> > On Thu, Jun 30, 2011 at 3:39 PM, Clinton Gormley \<[clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)
> > 
> > > wrote:
> > 
> > > Hi Sandeep
> > > 
> > > > ```
> > > > I want to apply facet in that query for find the valuable result
> > > > 
> > > > ```
> > > > 
> > > > my query is bellow which is not work properly-  
> > > > $ curl -XGET  
> > > > '[http://192.168.1.100:9200/mydb2/mytype2/\_search?pretty=true](http://192.168.1.100:9200/mydb2/mytype2/_search?pretty=true)' -d  
> > > > '{  
> > > > "filtered":{
> > > 
> > > Why do you have "filtered" on the line above?
> > > 
> > > The structure of a query is always:
> > > 
> > > [http://localhost:9200/index/type/\_search?pretty=true](http://localhost:9200/index/type/_search?pretty=true)' -d '  
> > > { query: {.....} }  
> > > '
> > > 
> > > The "query" must be at the top level. Always.
> > > 
> > > Then you have 3 choices:
> > > 
> > > 1. a query clause eg { text: { title: "john smith" }}
> > > 2. a filter clause eg { term: {status: "active" }}
> > > 3. a query and filter clause eg both of the above
> > > 
> > > If you have just a query, then you can add it directly:
> > > 
> > > { query: {  
> > > text: { title: "john smith" }  
> > > }}
> > > 
> > > If you have just a filter, then you should wrap it in a constant\_score  
> > > query:
> > > 
> > > { query: {  
> > > constant\_score: {  
> > > filter: {  
> > > term: { status: "active" }  
> > > }  
> > > }  
> > > }}
> > > 
> > > If you want to combine a query and a filter, then you should wrap them  
> > > in a filtered query:
> > > 
> > > { query: {  
> > > filtered: {  
> > > query: { text: { title: "john smith" }},  
> > > filter: { term: { status: "active" }}  
> > > }  
> > > }}
> > > 
> > > clint

---

<div class="post-metadata">

**Author:** ![sandeep15mca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandeep15mca/32/3178_2.png) [@sandeep15mca](https://discuss.elastic.co/u/sandeep15mca)\
**Post date:** [June 30, 2011, 10:36am UTC](https://discuss.elastic.co/t/search-query/4682/36 "2011-06-30T10:36:51Z")

</div>

'{  
"query":{  
"constant\_score" : {  
"filter" : {"or":[{  
"range" : {  
"date" : {  
"to" : "2011-09-10",  
"from" : "2011-09-01"

```
         }
      }
   }]

```

}}}}'  
Sir It is working properlly but when add facet as-  
'{  
"query":{  
"constant\_score" : {  
"filter" : {"or":[{  
"range" : {  
"date" : {  
"to" : "2011-09-10",  
"from" : "2011-09-01"

```
         }

```

},"facet":{"range":{"date":{"to":"2011-10-17","from":"2011-10-07"}}}

```
   }]

```

}}}}'  
it is producing error.  
please guide me.

On Thu, Jun 30, 2011 at 3:51 PM, sandeep tiwari [sandeep15mca@gmail.com](mailto:sandeep15mca@gmail.com)wrote:

> Sir!  
> curl -XGET '  
> [http://192.168.1.100:9200/mydb2/mytype2/\_search?pretty=true](http://192.168.1.100:9200/mydb2/mytype2/_search?pretty=true)' -d  
> '{  
> "query":{  
> "constant\_score" : {  
> "filter" : {"or":[{  
> "range" : {  
> "date" : {  
> "to" : "2011-09-10",  
> "from" : "2011-09-01"
> 
> ```
> }
> 
> ```
> 
> },"facet":{"range":{"date":{"to":"2011-10-17","from":"2011-10-07"}}}
> 
> ```
> }]
> 
> ```
> 
> }}  
> sorry sir inconvenience but it is not working even please help me
> 
> On Thu, Jun 30, 2011 at 3:42 PM, sandeep tiwari [sandeep15mca@gmail.com](mailto:sandeep15mca@gmail.com)wrote:
> 
> > thanks lot Sir.......
> > 
> > On Thu, Jun 30, 2011 at 3:39 PM, Clinton Gormley \<[clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)
> > 
> > > wrote:
> > 
> > > Hi Sandeep
> > > 
> > > > ```
> > > > I want to apply facet in that query for find the valuable result
> > > > 
> > > > ```
> > > > 
> > > > my query is bellow which is not work properly-  
> > > > $ curl -XGET  
> > > > '[http://192.168.1.100:9200/mydb2/mytype2/\_search?pretty=true](http://192.168.1.100:9200/mydb2/mytype2/_search?pretty=true)' -d  
> > > > '{  
> > > > "filtered":{
> > > 
> > > Why do you have "filtered" on the line above?
> > > 
> > > The structure of a query is always:
> > > 
> > > [http://localhost:9200/index/type/\_search?pretty=true](http://localhost:9200/index/type/_search?pretty=true)' -d '  
> > > { query: {.....} }  
> > > '
> > > 
> > > The "query" must be at the top level. Always.
> > > 
> > > Then you have 3 choices:
> > > 
> > > 1. a query clause eg { text: { title: "john smith" }}
> > > 2. a filter clause eg { term: {status: "active" }}
> > > 3. a query and filter clause eg both of the above
> > > 
> > > If you have just a query, then you can add it directly:
> > > 
> > > { query: {  
> > > text: { title: "john smith" }  
> > > }}
> > > 
> > > If you have just a filter, then you should wrap it in a constant\_score  
> > > query:
> > > 
> > > { query: {  
> > > constant\_score: {  
> > > filter: {  
> > > term: { status: "active" }  
> > > }  
> > > }  
> > > }}
> > > 
> > > If you want to combine a query and a filter, then you should wrap them  
> > > in a filtered query:
> > > 
> > > { query: {  
> > > filtered: {  
> > > query: { text: { title: "john smith" }},  
> > > filter: { term: { status: "active" }}  
> > > }  
> > > }}
> > > 
> > > clint

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [June 30, 2011, 10:41am UTC](https://discuss.elastic.co/t/search-query/4682/37 "2011-06-30T10:41:28Z")

</div>

> Sir It is working properlly but when add facet as-

OK! Progress!

> '{  
> "query":{  
> "constant\_score" : {  
> "filter" : {"or":[{  
> "range" : {  
> "date" : {  
> "to" : "2011-09-10",  
> "from" : "2011-09-01"
> 
> ```
> }
> 
> ```
> 
> },"facet":{"range":{"date":{"to":"2011-10-17","from":"2011-10-07"}}}
> 
> ```
> }]
> 
> ```
> 
> }}}}'

> it is producing error.

First: format your JSON nicely:  
{  
"query" : {  
"constant\_score" : {  
"filter" : {  
"or" : [  
{  
"range" : {  
"date" : {  
"to" : "2011-09-10",  
"from" : "2011-09-01"  
}  
},  
"facet" : {  
"range" : {  
"date" : {  
"to" : "2011-10-17",  
"from" : "2011-10-07"  
}  
}  
}  
}  
]  
}  
}  
}  
}

Second, look at the facets documentation and see if you have added the  
facets in the right place (or for that matter, used the right keywords!)

The docs are your friends.

---

<div class="post-metadata">

**Author:** ![sandeep15mca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandeep15mca/32/3178_2.png) [@sandeep15mca](https://discuss.elastic.co/u/sandeep15mca)\
**Post date:** [June 30, 2011, 11:22am UTC](https://discuss.elastic.co/t/search-query/4682/38 "2011-06-30T11:22:26Z")

</div>

Sir !  
All Things have been done perfectlly but result is unexpected please  
help me -  
'{  
"filtered":  
{  
"query":  
{  
"constant\_score" :  
{  
"filter" : {"or":[  
{  
"range" : {  
"date" : {  
"lte" : "2011-09-01",  
"gte" : "2011-09-10"

```
          }
       },
      "range":
              {
               "date":
                      {
                       "lte":"2011-10-17","gte": "2011-10-07"
                        }
                        }
    }
   ]
 }
}

```

}  
}'  
result is not right-  
{  
"took" : 2,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 10,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "mydb2",  
"\_type" : "mytype2",  
"\_id" : "1628606f4283247f269be3f8ce007c41",  
"\_score" : 1.0, "\_source" :  
{"\_rev":"5-1bbfb69b0f3e7bb45842a3f2d43b7d1d","  
author":"jacky","\_id":"1628606f4283247f269be3f8ce007c41","location":"austrelia",  
"date":"2011-10-15","type":"x","msg":"known by kangaroo"}  
}, {  
"\_index" : "mydb2",  
"\_type" : "mytype2",  
"\_id" : "5382de0ad052b255738f2de1ff075b9e",  
"\_score" : 1.0, "\_source" :  
{"\_rev":"3-73140e3038c85f0c7a5a421f9a1d8d25","  
author":"k.knight","\_id":"5382de0ad052b255738f2de1ff075b9e","location":"delhi","  
date":"2011-10-01","type":"x","msg":"hi hello"}  
}, {  
"\_index" : "mydb2",  
"\_type" : "mytype2",  
"\_id" : "1628606f4283247f269be3f8ce00486f",  
"\_score" : 1.0, "\_source" :  
{"\_rev":"3-1a50fdb7ab741b0f16d9c05bb8aacb71","  
author":"duglus","\_id":"1628606f4283247f269be3f8ce00486f","location":"mathura","  
date":"2011-09-01","type":"x","msg":"How are you"}  
}, {  
"\_index" : "mydb2",  
"\_type" : "mytype2",  
"\_id" : "1628606f4283247f269be3f8ce0086f5",  
"\_score" : 1.0, "\_source" :  
{"\_rev":"4-b249916c3956d7f265119f428e982495","  
author":"sarojini  
naidoo","\_id":"1628606f4283247f269be3f8ce0086f5","location":"h  
yderabad","date":"2011-10-10","type":"x","msg":"hi how r u"}  
}, {  
"\_index" : "mydb2",  
"\_type" : "mytype2",  
"\_id" : "1628606f4283247f269be3f8ce006335",  
"\_score" : 1.0, "\_source" :  
{"\_rev":"3-6d09665e0897d108ce722a8ee9b37256","  
author":"jhon","\_id":"1628606f4283247f269be3f8ce006335","location":"London","dat  
e":"2011-06-05","type":"x","msg":"hello london"}  
}, {  
"\_index" : "mydb2",  
"\_type" : "mytype2",  
"\_id" : "1628606f4283247f269be3f8ce005863",  
"\_score" : 1.0, "\_source" :  
{"\_rev":"4-ee087f9aec48f57d3aec7e8f33097425","  
author":"washington","\_id":"1628606f4283247f269be3f8ce005863","location":"NYK","  
date":"2011-09-04","type":"x","msg":"fine city"}  
}, {  
"\_index" : "mydb2",  
"\_type" : "mytype2",  
"\_id" : "1628606f4283247f269be3f8ce009380",  
"\_score" : 1.0, "\_source" :  
{"\_rev":"3-94981d7b9a9c8c651e6e7be82bb3cc55","  
author":"Dr. Harivans Rai  
Bachchan","\_id":"1628606f4283247f269be3f8ce009380","lo  
cation":"pratapgarh","date":"2011-04-06","type":"x","msg":"largest producer  
of a  
wla in india"}  
}, {  
"\_index" : "mydb2",  
"\_type" : "mytype2",  
"\_id" : "1628606f4283247f269be3f8ce008a27",  
"\_score" : 1.0, "\_source" :  
{"\_rev":"3-bc018d2f34386c7eed59e9833711c224","  
author":"sohan lal  
dwedi","\_id":"1628606f4283247f269be3f8ce008a27","location":"G  
haziabad","date":"2011-05-07","type":"x","msg":"hi GZB"}  
}, {  
"\_index" : "mydb2",  
"\_type" : "mytype2",  
"\_id" : "1628606f4283247f269be3f8ce006630",  
"\_score" : 1.0, "\_source" :  
{"\_rev":"3-a0d0d5064862047843577b3909b2b5e4","  
author":"smaller  
country","\_id":"1628606f4283247f269be3f8ce006630","location":"c  
uba","date":"2011-09-07","type":"x","msg":"hi cubian"}  
}, {  
"\_index" : "mydb2",  
"\_type" : "mytype2",  
"\_id" : "1628606f4283247f269be3f8ce007102",  
"\_score" : 1.0, "\_source" :  
{"\_rev":"4-88656c9daa4e4ed4dd993b03c8f732e3","  
author":"tim Bernar  
lee","\_id":"1628606f4283247f269be3f8ce007102","location":"So  
uth frica","date":"2011-10-07","type":"x","msg":"hi africa"}  
} ]  
}  
}here  
----------curl: (3) [globbing] nested braces not supported at pos  
8----------------------this part is showing "here place" which not should be  
in result  
please sir check it

```
                                                   thanks.

```

On Thu, Jun 30, 2011 at 4:11 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:

> > Sir It is working properlly but when add facet as-
> 
> OK! Progress!
> 
> > '{  
> > "query":{  
> > "constant\_score" : {  
> > "filter" : {"or":[{  
> > "range" : {  
> > "date" : {  
> > "to" : "2011-09-10",  
> > "from" : "2011-09-01"
> > 
> > ```
> > }
> > 
> > ```
> > 
> > },"facet":{"range":{"date":{"to":"2011-10-17","from":"2011-10-07"}}}
> > 
> > ```
> > }]
> > 
> > ```
> > 
> > }}}}'
> 
> > it is producing error.
> 
> First: format your JSON nicely:  
> {  
> "query" : {  
> "constant\_score" : {  
> "filter" : {  
> "or" : [  
> {  
> "range" : {  
> "date" : {  
> "to" : "2011-09-10",  
> "from" : "2011-09-01"  
> }  
> },  
> "facet" : {  
> "range" : {  
> "date" : {  
> "to" : "2011-10-17",  
> "from" : "2011-10-07"  
> }  
> }  
> }  
> }  
> ]  
> }  
> }  
> }  
> }
> 
> Second, look at the facets documentation and see if you have added the  
> facets in the right place (or for that matter, used the right keywords!)
> 
> The docs are your friends.

---

<div class="post-metadata">

**Author:** ![sandeep15mca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sandeep15mca/32/3178_2.png) [@sandeep15mca](https://discuss.elastic.co/u/sandeep15mca)\
**Post date:** [June 30, 2011, 11:24am UTC](https://discuss.elastic.co/t/search-query/4682/39 "2011-06-30T11:24:21Z")

</div>

Sorry sir result is previous is correct but query is this-

On Thu, Jun 30, 2011 at 4:52 PM, sandeep tiwari [sandeep15mca@gmail.com](mailto:sandeep15mca@gmail.com)wrote:

> Sir !  
> All Things have been done perfectlly but result is unexpected please  
> help me -  
> '{  
> "filtered":  
> {
> 
> {"facet":{"query":{  
> "constant\_score" : {  
> "filter" : {"or":[{  
> "range" : {  
> "date" : {  
> "to" : "2011-09-01",  
> "from" : "2011-09-10"
> 
> ```
> }
> },"range":{"date":{"to":"2011-10-17","from":"2011-10-07"}}
> }]
> }
> 
> ```
> 
> }  
> }}'  
> "query":  
> {  
> "constant\_score" :  
> {  
> "filter" : {"or":[  
> {  
> "range" : {  
> "date" : {  
> "lte" : "2011-09-01",  
> "gte" : "2011-09-10"
> 
> ```
> }
> },
> "range":
> {
> "date":
> {
> "lte":"2011-10-17","gte": "2011-10-07"
> }
> }
> }
> ]
> }
> }
> 
> ```
> 
> }  
> }'  
> result is not right-  
> {  
> "took" : 2,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 10,  
> "max\_score" : 1.0,  
> "hits" : [ {  
> "\_index" : "mydb2",  
> "\_type" : "mytype2",  
> "\_id" : "1628606f4283247f269be3f8ce007c41",  
> "\_score" : 1.0, "\_source" :  
> {"\_rev":"5-1bbfb69b0f3e7bb45842a3f2d43b7d1d","
> 
> author":"jacky","\_id":"1628606f4283247f269be3f8ce007c41","location":"austrelia",  
> "date":"2011-10-15","type":"x","msg":"known by kangaroo"}  
> }, {  
> "\_index" : "mydb2",  
> "\_type" : "mytype2",  
> "\_id" : "5382de0ad052b255738f2de1ff075b9e",  
> "\_score" : 1.0, "\_source" :  
> {"\_rev":"3-73140e3038c85f0c7a5a421f9a1d8d25","
> 
> author":"k.knight","\_id":"5382de0ad052b255738f2de1ff075b9e","location":"delhi","  
> date":"2011-10-01","type":"x","msg":"hi hello"}  
> }, {  
> "\_index" : "mydb2",  
> "\_type" : "mytype2",  
> "\_id" : "1628606f4283247f269be3f8ce00486f",  
> "\_score" : 1.0, "\_source" :  
> {"\_rev":"3-1a50fdb7ab741b0f16d9c05bb8aacb71","
> 
> author":"duglus","\_id":"1628606f4283247f269be3f8ce00486f","location":"mathura","  
> date":"2011-09-01","type":"x","msg":"How are you"}  
> }, {  
> "\_index" : "mydb2",  
> "\_type" : "mytype2",  
> "\_id" : "1628606f4283247f269be3f8ce0086f5",  
> "\_score" : 1.0, "\_source" :  
> {"\_rev":"4-b249916c3956d7f265119f428e982495","  
> author":"sarojini  
> naidoo","\_id":"1628606f4283247f269be3f8ce0086f5","location":"h  
> yderabad","date":"2011-10-10","type":"x","msg":"hi how r u"}  
> }, {  
> "\_index" : "mydb2",  
> "\_type" : "mytype2",  
> "\_id" : "1628606f4283247f269be3f8ce006335",  
> "\_score" : 1.0, "\_source" :  
> {"\_rev":"3-6d09665e0897d108ce722a8ee9b37256","
> 
> author":"jhon","\_id":"1628606f4283247f269be3f8ce006335","location":"London","dat  
> e":"2011-06-05","type":"x","msg":"hello london"}  
> }, {  
> "\_index" : "mydb2",  
> "\_type" : "mytype2",  
> "\_id" : "1628606f4283247f269be3f8ce005863",  
> "\_score" : 1.0, "\_source" :  
> {"\_rev":"4-ee087f9aec48f57d3aec7e8f33097425","
> 
> author":"washington","\_id":"1628606f4283247f269be3f8ce005863","location":"NYK","  
> date":"2011-09-04","type":"x","msg":"fine city"}  
> }, {  
> "\_index" : "mydb2",  
> "\_type" : "mytype2",  
> "\_id" : "1628606f4283247f269be3f8ce009380",  
> "\_score" : 1.0, "\_source" :  
> {"\_rev":"3-94981d7b9a9c8c651e6e7be82bb3cc55","  
> author":"Dr. Harivans Rai  
> Bachchan","\_id":"1628606f4283247f269be3f8ce009380","lo  
> cation":"pratapgarh","date":"2011-04-06","type":"x","msg":"largest producer  
> of a  
> wla in india"}  
> }, {  
> "\_index" : "mydb2",  
> "\_type" : "mytype2",  
> "\_id" : "1628606f4283247f269be3f8ce008a27",  
> "\_score" : 1.0, "\_source" :  
> {"\_rev":"3-bc018d2f34386c7eed59e9833711c224","  
> author":"sohan lal  
> dwedi","\_id":"1628606f4283247f269be3f8ce008a27","location":"G  
> haziabad","date":"2011-05-07","type":"x","msg":"hi GZB"}  
> }, {  
> "\_index" : "mydb2",  
> "\_type" : "mytype2",  
> "\_id" : "1628606f4283247f269be3f8ce006630",  
> "\_score" : 1.0, "\_source" :  
> {"\_rev":"3-a0d0d5064862047843577b3909b2b5e4","  
> author":"smaller  
> country","\_id":"1628606f4283247f269be3f8ce006630","location":"c  
> uba","date":"2011-09-07","type":"x","msg":"hi cubian"}  
> }, {  
> "\_index" : "mydb2",  
> "\_type" : "mytype2",  
> "\_id" : "1628606f4283247f269be3f8ce007102",  
> "\_score" : 1.0, "\_source" :  
> {"\_rev":"4-88656c9daa4e4ed4dd993b03c8f732e3","  
> author":"tim Bernar  
> lee","\_id":"1628606f4283247f269be3f8ce007102","location":"So  
> uth frica","date":"2011-10-07","type":"x","msg":"hi africa"}  
> } ]  
> }  
> }here  
> ----------curl: (3) [globbing] nested braces not supported at pos  
> 8----------------------this part is showing "here place" which not should be  
> in result  
> please sir check it
> 
> ```
> thanks.
> 
> ```
> 
> On Thu, Jun 30, 2011 at 4:11 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:
> 
> > > Sir It is working properlly but when add facet as-
> > 
> > OK! Progress!
> > 
> > > '{  
> > > "query":{  
> > > "constant\_score" : {  
> > > "filter" : {"or":[{  
> > > "range" : {  
> > > "date" : {  
> > > "to" : "2011-09-10",  
> > > "from" : "2011-09-01"
> > > 
> > > ```
> > > }
> > > 
> > > ```
> > > 
> > > },"facet":{"range":{"date":{"to":"2011-10-17","from":"2011-10-07"}}}
> > > 
> > > ```
> > > }]
> > > 
> > > ```
> > > 
> > > }}}}'
> > 
> > > it is producing error.
> > 
> > First: format your JSON nicely:  
> > {  
> > "query" : {  
> > "constant\_score" : {  
> > "filter" : {  
> > "or" : [  
> > {  
> > "range" : {  
> > "date" : {  
> > "to" : "2011-09-10",  
> > "from" : "2011-09-01"  
> > }  
> > },  
> > "facet" : {  
> > "range" : {  
> > "date" : {  
> > "to" : "2011-10-17",  
> > "from" : "2011-10-07"  
> > }  
> > }  
> > }  
> > }  
> > ]  
> > }  
> > }  
> > }  
> > }
> > 
> > Second, look at the facets documentation and see if you have added the  
> > facets in the right place (or for that matter, used the right keywords!)
> > 
> > The docs are your friends.

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [June 30, 2011, 11:35am UTC](https://discuss.elastic.co/t/search-query/4682/40 "2011-06-30T11:35:33Z")

</div>

On Thu, 2011-06-30 at 16:54 +0530, sandeep tiwari wrote:

> Sorry sir result is previous is correct but query is this-

> ```
> All Things have been done perfectlly but result is
> unexpected please help me -
> 
> ```

Sandeep - you clearly haven't read the docs. Go do so - I can't help you  
if you won't help yourself.

clint

[Previous page](https://discuss.elastic.co/t/search-query/4682.md?page=1)

[Next page](https://discuss.elastic.co/t/search-query/4682.md?page=3)
