Hi people,
I have executed this query into production, it tooks 2 seconds:
CURL -XGET 'http://blablabla/_search?routing=061500000015181033' -d '
{
  "size": 0,
  "query": {
    "filtered": {
      "query": {
        "term": {
          "blabla": "035345353"
        }
      },
      "filter": {
        "range": {
          "fecha": {
            "from": "20130101",
            "to": "20150501",
            "include_lower": true,
            "include_upper": true
          }
        }
      }
    }
  },
  "aggs": {
    "Sectores": {
      "terms": {
        "field": "descripcionSector"
      },
      "aggs": {
        "sumaSector": {
          "sum": {
            "field": "importe"
          }
        },
        "Subsectores": {
          "terms": {
            "field": "descripcionSubsector"
          },
          "aggs": {
            "sumaSubSector": {
              "sum": {
                "field": "importe"
              }
            }
          }
        }
      }
    }
  }
}'
and this one only took 159 ms
curl -XGET 'http://blablabla/_search?routing=061500000015181033' -d '
{
  "size": 0,
  "query": {
    "term": {
      "blala": "061500000015181033"
    }
  },
  "filter": {
    "range": {
      "fecha": {
        "gte": 20130101
      }
    }
  },
  "aggs": {
    "Sectores": {
      "terms": {
        "field": "descripcionSector"
      },
      "aggs": {
        "sumaSector": {
          "sum": {
            "field": "importe"
          }
        },
        "Subsectores": {
          "terms": {
            "field": "descripcionSubsector"
          },
          "aggs": {
            "sumaSubSector": {
              "sum": {
                "field": "importe"
              }
            }
          }
        }
      }
    }
  }
}'
Server was attending same level of requests at the time of executing, no overload...so why there's so much time difference? I guess caching is involved, but I thought filteredQuery was faster...
Does anyone can help me to understand this?
Regards