I agree. But then the only way to use dynamically generated "should clause(s)" is to include a mandatory "must clause" with some identity function i.e. added overhead. I also tried "minimum_should_match" of 0, but it gave 0 documents in result. I was expecting every document in the index as result.
Is it a bug or feature? Should it be reported? On Thursday, March 12, 2015 at 9:20:12 PM UTC+1, Les Barstow wrote: > > "should" has a "minimum_should_match" of 1 when there is no "must" or > "must_not". With only a single "should", that makes it act like "must". > > On Thu, Mar 12, 2015 at 9:08 AM, parq <[email protected] <javascript:>> > wrote: > >> 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] <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elasticsearch/58b7f178-4c09-4de7-9d38-c7aa3bc39a05%40googlegroups.com >> >> <https://groups.google.com/d/msgid/elasticsearch/58b7f178-4c09-4de7-9d38-c7aa3bc39a05%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/a1c2a083-c8d2-4108-a91f-b87a8e8d500d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
