# Source filtering ONLY on suggestions

**URL:** <https://discuss.elastic.co/t/source-filtering-only-on-suggestions/183401>\
**Category:** Elasticsearch\
**Created:** [May 29, 2019, 6:24pm UTC](https://discuss.elastic.co/t/source-filtering-only-on-suggestions/183401 "2019-05-29T18:24:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![leguma](https://avatars.discourse-cdn.com/v4/letter/l/8dc957/32.png) [@leguma](https://discuss.elastic.co/u/leguma)\
**Post date:** [May 29, 2019, 6:24pm UTC](https://discuss.elastic.co/t/source-filtering-only-on-suggestions/183401/1 "2019-05-29T18:24:33Z")

</div>

It seems very odd that source filtering is only allowed at the root of the \_search request. This should be legal:

```auto
{
    "suggest": {
    	"text": "A cool titl",
        "typeahead-suggest" : {
            "completion" : {
                "_source": false,
               // STUFF
            }
        }
    }
}

```

The reason being that typeahead suggestions are likely going to be used as a fallback for a standard search & phrase-suggest like so:

```auto
{
    "query": {
        // STUFF
    },
	"suggest": {
		"text": "A cool titl",
		"typeahead-suggest" : {
			"completion" : { 
				"field" : "typeahead",
				"size": 5,
				"fuzzy": {
					"fuzziness": 2
				}
			}
		},
		"phrase-suggest": {
		  "phrase": {
			"field": "suggestions",
			"size": 5,
			"highlight": {
			  "pre_tag": "<em>",
			  "post_tag": "</em>"
			}
		  }
	   }
	}
}

```

As with SOLR, this is often useful so that the client does not have to make a second request when there are no search hits. First, we fall back on phrase suggestions, and finally on typahead suggestions as a last resort (they use somewhat different match criteria, so sometimes this is useful). In this case, usually we don't need \_source information on the suggestions, so filtering these out can improve performance. However, source filtering can only be done at the root of the request, which means we're stuck with a global on/off of \_source information for all of our response.

Anyone know of a way to toss the source just on the typeahead suggestions above?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 26, 2019, 6:24pm UTC](https://discuss.elastic.co/t/source-filtering-only-on-suggestions/183401/2 "2019-06-26T18:24:42Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
