However, the following query returns the expected document,

curl -XGET "http://localhost:9200/test-cbx/bug/_search"; -d'
{
   "query": {
      "filtered": {
         "query": {
            "bool": {
                "must": [
                   {
                       "match": {
                          "type": {
                              "query": "some type"
                          
                          }
                       }
                   }
                ],
                "should": [
                   {
                       "match": {
                          "country": {
                              "query": "de"
                          
                          }
                       }
                   }
                ]
            }
         },
         "filter": {
                  "term": {
                     "type": "some type"
                  }
         }
      }
   }
}'

May be it is like "should clause" does not work without a "Must clause" in 
query? 


On Thursday, March 12, 2015 at 2:54:00 PM UTC+1, parq wrote:
>
> Hello all,
>
> We have a single document in an index: 
>
> $  curl -XGET "http://localhost:9200/test-cbx/bug/_search?q=*";  gives us 
> the following response
>
> {"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":[{"_index":"test-cbx","_type":"bug","_id":"1","_score":1.0,"_source":
> {
>     "country": "lu",
>     "type": “some type"
> }}]}}
>
> And the following two queries give no results, even though it’s a should 
> clause:
>
> $ curl -XGET "http://localhost:9200/test-cbx/bug/_search"; -d'
> {
>    "query": {
>       "filtered": {
>          "query": {
>             "match_all": {}
>          },
>          "filter": {
>             "bool": {
>                "should": {
>                   "term": {
>                      "country": "de"
>                   }
>                }
>             }
>          }
>       }
>    }
> }'
>
> $ curl -XGET "http://localhost:9200/test-cbx/bug/_search"; -d'
> {
>    "query": {
>       "filtered": {
>          "query": {
>             "bool": {
>                 "should": [
>                    {
>                        "match": {
>                           "country": {
>                               "query": "de"
>                           
>                           }
>                        }
>                    }
>                 ]
>             }
>          },
>          "filter": {
>                   "term": {
>                      "type": “some type"
>                   }
>          }
>       }
>    }
> }'
>
> What is the preferred way to approach the bool query? Filter or the query?
>
>
> Regards,
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/58b7f178-4c09-4de7-9d38-c7aa3bc39a05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to