Determine the cardinality of indexed field in a reliable way
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3555399. -->
Reported by: [a.dmitriiev](https://www.drupal.org/user/3235287)
Related to !985 !11
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>The embedding base class has method getValue that does some assumptions regarding the cardinality of the field, this assumption is based on the number of items in field value, but it could be the case that multivalue field has only 1 value, but it doesn’t mean that the field itself is not a multivalue field.</p>
<p>The problem is that some vector databases, like Azure, for example, are very strict on cardinality, if the field can have multiple values, its definition on Azure is of course Array/Colletion. Then when the field has only one value, embedding strategy tries to flatten it, because it assumes it to be single valued, and then indexing fails, because Azure expects an array/collection.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>I suggest that the method <code>isMultiple</code> from <code>AiVdbProviderClientBase</code> is used instead <code>count($values)</code> as it is now. For this, the embedding strategy should be aware of the VdbProviderClient that uses it to use <code>isMultiple</code> method from it.</p>
> Related issue: [Issue #3528233](https://www.drupal.org/node/3528233)
issue