Search across types with same fields, different stored settings

I have an index where I defined some stored fields for a given type. I then had some docs that I didn't need to define a mapping and just threw them in the same index under a different type. I perform a search across both types and ask for the stored fields back. The results for the type with the stored fields has the fields returned, but the results for the type that I did not set the stored field does not return the fields. The field names are the same across each type. I expected the fields that were not stored to be pulled from the source but that does not seem to be the case. I read in the docs that said it is recommended that types with the same fields names is recommend to have the same mappings, so maybe this is just a problem with that. Considering both are string fields, analyzed the same, and the difference is only stored vs. not stored, it might be a bug?

Here is a gist showing the problem:

--
Matt Weber
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

Yes, there is an optimization to not check each mapping specifically per hit, but try to guess what to fetch on the "search" level (and not per hit) and then use it for all the hits. We can improve it though, open an issue?

On Saturday, February 18, 2012 at 6:48 PM, Matt Weber wrote:

I have an index where I defined some stored fields for a given type. I then had some docs that I didn't need to define a mapping and just threw them in the same index under a different type. I perform a search across both types and ask for the stored fields back. The results for the type with the stored fields has the fields returned, but the results for the type that I did not set the stored field does not return the fields. The field names are the same across each type. I expected the fields that were not stored to be pulled from the source but that does not seem to be the case. I read in the docs that said it is recommended that types with the same fields names is recommend to have the same mappings, so maybe this is just a problem with that. Considering both are string fields, analyzed the same, and the difference is only stored vs. not stored, it might be a bug?

Here is a gist showing the problem:

mapping · GitHub

--
Matt Weber
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

Thanks. improve fetch optimizations · Issue #1721 · elastic/elasticsearch · GitHub

--
Matt Weber
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Monday, February 20, 2012 at 5:00 AM, Shay Banon wrote:

Yes, there is an optimization to not check each mapping specifically per hit, but try to guess what to fetch on the "search" level (and not per hit) and then use it for all the hits. We can improve it though, open an issue?

On Saturday, February 18, 2012 at 6:48 PM, Matt Weber wrote:

I have an index where I defined some stored fields for a given type. I then had some docs that I didn't need to define a mapping and just threw them in the same index under a different type. I perform a search across both types and ask for the stored fields back. The results for the type with the stored fields has the fields returned, but the results for the type that I did not set the stored field does not return the fields. The field names are the same across each type. I expected the fields that were not stored to be pulled from the source but that does not seem to be the case. I read in the docs that said it is recommended that types with the same fields names is recommend to have the same mappings, so maybe this is just a problem with that. Considering both are string fields, analyzed the same, and the difference is only stored vs. not stored, it might be a bug?

Here is a gist showing the problem:

mapping · GitHub

--
Matt Weber
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)