Currently, calls to field caps API don't use a filter in order to get access to all data and not avoid false negatives - however this is expensive since the entire mapping has to be read.
To improve performance we can use an optimistic approach by invoking the API with an index filter and, in case not all fields are found issue a second call without a filter.
Overall this will be more expensive than one call however we're estimating that:
the first call will succeed more often than not
the first call will be cheaper
the delta between the first and second call, gives us insight around fields are excluded by the filter which can be at planning time.
Description
Currently, calls to field caps API don't use a filter in order to get access to all data and not avoid false negatives - however this is expensive since the entire mapping has to be read. To improve performance we can use an optimistic approach by invoking the API with an index filter and, in case not all fields are found issue a second call without a filter. Overall this will be more expensive than one call however we're estimating that: