# Difference between filter\_path and \_source\_include?

**URL:** <https://discuss.elastic.co/t/difference-between-filter-path-and--source-include/31903>\
**Category:** Elasticsearch\
**Created:** [October 9, 2015, 11:20am UTC](https://discuss.elastic.co/t/difference-between-filter-path-and--source-include/31903 "2015-10-09T11:20:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![trycoon](https://avatars.discourse-cdn.com/v4/letter/t/dfb087/32.png) [@trycoon](https://discuss.elastic.co/u/trycoon)\
**Post date:** [October 9, 2015, 11:20am UTC](https://discuss.elastic.co/t/difference-between-filter-path-and--source-include/31903/1 "2015-10-09T11:20:32Z")

</div>

Currently I have made two different APIs in my application, one does a Search against Elastic Search and the other one does a Template Search. In the first one I use \_source\_include to let the client specify which field in the hits they are interested in, and it's working great!

The other API that using searchTemplate can't use \_source\_include since that function is only available for standard search ([https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-search](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-search)), the searchTemplate is much slimmer ([https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-searchtemplate](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-searchtemplate)). But there is a filterPath-property that seems to do the same thing and that is available for all query-command as I understand it: [https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-conventions.html](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-conventions.html). What is the difference between them? Could we not just use filterPath everywhere and throw \_source\_include away? Unfortunately I can't get filterPath to work, it gives me everything and not just those properties that I'm trying to filter out. I there something I'am doing something wrong?

2015-10-09T11:17:21.120Z: 2015-10-09T11:17:21.118Z - debug: [elasticSearch] starting request  
{ method: 'POST',  
path: '/test2\_content/content/\_search/template',  
body:  
{ template: { id: 'test2.content.clusterTemplate' },  
params: { } },  
query:  
{ search\_type: 'query\_then\_fetch',  
filter\_path: 'payload.version',  
explain: false,  
from: 0,  
size: 10 } }

Running Elastic Search 1.7  
Javascript library [https://github.com/elastic/elasticsearch-js](https://github.com/elastic/elasticsearch-js) version 8.2.0 with API-version 1.7

Thanks!

---

<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:** [July 5, 2017, 11:45pm UTC](https://discuss.elastic.co/t/difference-between-filter-path-and--source-include/31903/2 "2017-07-05T23:45:40Z")

</div>


