In elastic search, this filter
{
"bool": {
"must": {
"term": {
"article.title": "google"
}
}
}
}
Properly returns articles with "google" in the title.
However,
{
"bool": {
"must": {
"term": {
"article.title": "google earth"
}
}
}
}
Does not return any results, despite the fact that there are articles with the exact words "google earth" in the title. I would like it to do so.
The full query:
{
"size": 200,
"filter": {
"bool": {
"must": {
"term": {
"article.title": "google maps"
}
}
}
},
{
"range": {
"created_date": {
"from": "2013-01-11T02:14:03.352Z"
}
}
}]
}
}
As you can see, I don't have a "query" -- just a filter, size, and range. So I take it that ElasticSearch is using the default analyzer...?
What am I misunderstanding?
EDIT: For those looking for the solution, here is my filter:
{
"query": {
"bool": {
"must": {
"must_match": {
"article.title": "google earth"
}
}
}
}
}
Node that (1) we wrapped the bool filter with "query" and (2) the "term" changed to a "must_match", which causes the entire phrase to be matched (as opposed to "match" which would search the article.title with a standard analyzer on google earth).
The full query looks like this:
{
"size": 200,
"filter": {
"query": {
"bool": {
"must": {
"must_match": {
"article.title": "google earth"
}
}
}
}
}
}
FWIW, the reason I have this condition within the "filter" field (as opposed to using a standard query) is that sometimes I want to use a "must_not" instead of a "must_not", and sometimes I also add other elements to the query.