# Custom fields for each type

**URL:** <https://discuss.elastic.co/t/custom-fields-for-each-type/38974>\
**Category:** Elasticsearch\
**Created:** [January 12, 2016, 12:08pm UTC](https://discuss.elastic.co/t/custom-fields-for-each-type/38974 "2016-01-12T12:08:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wkrugiolka](https://avatars.discourse-cdn.com/v4/letter/w/f475e1/32.png) [@wkrugiolka](https://discuss.elastic.co/u/wkrugiolka)\
**Post date:** [January 12, 2016, 12:08pm UTC](https://discuss.elastic.co/t/custom-fields-for-each-type/38974/1 "2016-01-12T12:08:54Z")

</div>

Hi,

is it possible to return different source fields for different document types?  
or query different fields for different types?

I would like to do something like this but in one request:

curl -XGET '[http://localhost:9200/my-index/MYTYPE1/\_search?pretty](http://localhost:9200/my-index/MYTYPE1/_search?pretty)' -d '{  
"\_source": ["MYTYPE1.field1"],  
"min\_score": 1,  
"query": {  
"bool" : {  
"must" : {  
"query\_string" : {  
"fields" : ["MYTYPE1.field1"],  
"query" : "queryString~\*"  
}  
}  
}  
}  
}  
'

curl -XGET '[http://localhost:9200/my-index/MYTYPE2/\_search?pretty](http://localhost:9200/my-index/MYTYPE2/_search?pretty)' -d '{  
"\_source": ["MYTYPE2.field1", "MYTYPE2.field2"],  
"min\_score": 1,  
"query": {  
"bool" : {  
"must" : {  
"query\_string" : {  
"fields" : ["MYTYPE2.field2"],  
"query" : "queryString~\*"  
}  
}  
}  
}  
}  
'

Regards, Wojtas

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 14, 2016, 6:46am UTC](https://discuss.elastic.co/t/custom-fields-for-each-type/38974/2 "2016-01-14T06:46:04Z")

</div>

I don't believe you can, no.

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [January 14, 2016, 9:34am UTC](https://discuss.elastic.co/t/custom-fields-for-each-type/38974/3 "2016-01-14T09:34:40Z")

</div>

You could use the [multi search API](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/search-multi-search.html) to do this in one request. It would still be running separate searches on the elasticsearch cluster so you would still get 10 hits per type but you would get the results in a single response. This is probably the closest to what you want that is possible currently

---

<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:24pm UTC](https://discuss.elastic.co/t/custom-fields-for-each-type/38974/4 "2017-07-05T23:24:38Z")

</div>


