I've seen lots of questions in S.O as well as reading the documentation about "filters are cached" while queries are not cached and that "queries are applied on all values" and "filters are applied after queries if outside the query object" etc.
Bottom line is that the documentation sucks and the DSL is very difficult to grasp. I'm trying to optimize some queries and using the kibana dev tools search profiler, but my local data sets must be too small to measure the actual performance difference (I'm getting results in both directions) and I don't have a test cluster with multiple nodes to work against on a real and large data set.
In this trivial case, all queries will return the same results. I want to understand the difference and why would you prefer a query rather than a filter in any cases that would allow to place the clause in a filter instead
GET foo11/_search
{
"query": {
"bool": {
"filter": {
"match" : {
"in_stock" : true
}
}
}
}
}
GET foo11/_search
{
"query": {
"bool": {
"filter": {
"term" : {
"in_stock" : true
}
}
}
}
}
GET foo11/_search
{
"query": {
"bool": {
"must": {
"match" : {
"in_stock" : true
}
}
}
}
}
what is the difference in these 3 cases in the performance? Can I actually prove that one is better/worse than the other?
What is the difference between:
"match" : {
"in_stock" : true
}
vs
"term" : {
"in_stock" : true
}