Query_string within background_filter in significant terms aggregation

Hi,

Is there a way to use a filter with a query_string query within the background_filter of a significant terms aggregation (on ES 2.1)? It seems like the background filter will not accept a query_string even within a filter context. Replacing it with a match query works. It seems like maybe the query parsing is not enabled within background_filter in significant terms?

Working for me on 2.3 and the LastFM data.

No background filter and a search for an old French hip-hop artist:

GET lastfmusers2/_search
{
   "query": {
	  "match": {
		 "artists.raw": "mc solaar"
	  }
   },
   "size": 0,
   "aggs": {
	  "keywords": {
		 "significant_terms": {
			"field": "artists.raw"
		 }
	  }
   }
}

.. returns other French hip-hop artists e.g. Iam

If we set a background_filter for "France" with the same seed artist query:

GET lastfmusers2/_search
{
   "query": {
	  "match": {
		 "artists.raw": "mc solaar"
	  }
   },
   "size": 0,
   "aggs": {
	  "keywords": {
		 "significant_terms": {
			"field": "artists.raw",
			"background_filter": {
			   "query_string": {
				  "query": "country:france"
			   }
			}
		 }
	  }
   }
}

.. and I get "pioneers of German hip-hop Die Fantastischen Vier" (at least according to Spotify).

1 Like