Fix support of non-content entity SearchAPI datasources
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3575999. --> Reported by: [mxr576](https://www.drupal.org/user/315522) Related to !25 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>We have a homegrown Search API that indexes things :tm: but they are not content entities and the data source does not extend <code>\Drupal\search_api\Plugin\search_api\datasource\ContentEntity</code>. </p> <p>Adding field from that data source is not possible OOTB due to how <code>\Drupal\ai_search\Form\AiSearchIndexFieldsForm::buildForm()</code> alters Search API's own form and hardcoded entity data source dependency.</p> <p>After that issue gets mitigated and you try to index data from that data source the following error is triggered:</p> <pre>Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager-&gt;getDefinition() (line 139 of /var/www/html/web/core/lib/Drupal/Core/Entity/EntityTypeMana1ger.php).<br><br>#0 /var/www/html/web/modules/contrib/ai/modules/ai_search/src/Plugin/EmbeddingStrategy/EmbeddingBase.php(174): Drupal\Core\Entity\EntityTypeManager-&gt;getDefinition()<br>#1 /var/www/html/web/modules/contrib/ai/modules/ai_search/src/Plugin/EmbeddingStrategy/EmbeddingBase.php(46): Drupal\ai_search\Plugin\EmbeddingStrategy\EmbeddingBase-&gt;groupFieldData()<br>#2 /var/www/html/web/modules/contrib/ai_provider_amazeeio/src/Vdb/Postgres/Plugin/VdbProvider/PostgresProvider.php(518): Drupal\ai_search\Plugin\EmbeddingStrategy\EmbeddingBase-&gt;getEmbedding()</pre><p>Access checking also depends on the assumption that the indexed data is a (content) entity. As a first step, that assumption has to be fixed and as a second step a new API should be introduced in a follow up issue (<span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/ai_search/-/work_items/3579758" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/ai_search/-/work_items/3579758</a></span>) for running access checks on other types of indexed data.</p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Removed hardcoded expectation from the code that only content entities can be indexed.</p> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <h3 id="summary-ui-changes">User interface changes</h3> <h3 id="summary-api-changes">API changes</h3> <h3 id="summary-data-model-changes">Data model changes</h3> > Related issue: [Issue #3575992](https://www.drupal.org/node/3575992)
issue