Hi.
When learning DSL, I have the following scene.
First, my mapping like this:
PUT /gb
{
"mappings": {
"tweet" : {
"properties" : {
"tweet" : {
"type" : "string",
"analyzer": "english"
},
"date" : {
"type" : "date"
}
}
}
}
}
Then, I put three documents:
PUT /gb/tweet/1
{
"tweet": "my first tweet",
"date": "2016-01-01"
}
PUT /gb/tweet/2
{
"tweet": "my second tweet",
"date": "2016-01-02"
}
PUT /gb/tweet/3
{
"tweet": "my third tweet",
"date": "2016-01-03"
}
Finally, I use the following two querys to search my data:
GET /gb/tweet/_search
{
"query": {
"bool": {
"must": {"match": {"tweet": "my tweet"}},
"should": {"match": {"tweet": "first"}}
}
}
}
GET /gb/tweet/_search
{
"query": {
"bool": {
"filter": {
"bool": {
"must": {"match": {"tweet": "my tweet"}},
"should": {"match": {"tweet": "first"}}
}
}
}
}
}
only return the first document
The first query returns all three documents, while the second query only returns the first query.
what's the difference between the two query?