Ok. I think I understand now.
You want to get docs that not contain a but you don't want to get docs
when a is not abcd.
I think you should give a look at the MultiMatch Query:
Elasticsearch Platform — Find real-time answers at scale | Elastic
David.
Le 6 novembre 2012 à 08:44, azi <azi...@gmail.com <javascript:>> a
écrit :
Should means at least one(or otherwise mentioned) of the conditions
specified should match.
So If I say:
should a=abcd
should b=wzyz
This will give me all documents which match the condition (the value of
'a' is abcd and the value of 'b' is wxyz) or (the value of 'a' is abcd and
tag 'b' doesn't exist) or (tag a doesn't exist and the value of 'b' is
wxyz).
But what I want in return is all documents which match the condition (the
value of 'a' is abcd and the value of 'b' is wxyz) or (the value of 'a' is
abcd and tag 'b' doesn't exist) or (tag a doesn't exist and the value of
'b' is wxyz) or (tag 'a' doesn't exist and tag 'b' doesn't exist).
Correct me if I am wrong.
-Azitabh
On Tuesday, 6 November 2012 12:55:36 UTC+5:30, David Pilato wrote:
"Should" means that the query is not mandatory.
If you have a 3rd condition (mandatory or a MatchAll), you can create a
bool query with :
Must -> Your Mandatory Query or MatchAll
Should -> TermQuery on "a"
Should -> TermQuery on "b"
It should work. Or I did not fully understand your use case.
HTH
--
David
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
Le 6 nov. 2012 à 08:16, azi < azi...@gmail.com> a écrit :
Thanks David.
But I missed a condition in my earlier post.
I also want documents in return which doesn't have any of the tag a & b.
Which simply means that I want to match a & b only if those are there.
This I don't think can be modeled in the bool query you have suggested.
-Azitabh
On Tuesday, 6 November 2012 12:38:55 UTC+5:30, David Pilato wrote:
You can wrap 2 queries in a Bool Query with should clauses.
That means that the doc which hit the two queries will have an higher
score.
See
Elasticsearch Platform — Find real-time answers at scale | Elastic
--
David http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
Le 6 nov. 2012 à 07:39, azi <http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html
azi...@gmail.com> a écrit :
Lets say I have a set of document which have a-z as keys.
And I am firing this term query:
curl -X GET localhost:9200/memphis/pincode/_search?pretty=json -d
'{"query":{"term":{"a":"abcd", "b":"wxyz"}}}'
This will return me all the documents for which the value of 'a' is abcd
and the value of 'b' is wxyz.
But, what if I want all the such documents in return for which (the value
of 'a' is abcd and the value of 'b' is wxyz) or (the value of 'a' is abcd
and tag 'b' doesn't exist) or (tag a doesn't exist and the value of 'b' is
wxyz).
Is this possible.
Thanks In Advance
-Azitabh
--
--
--
--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs