Support vector search by user supplied vectors in AI Search
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3489566. -->
Reported by: [vivek panicker](https://www.drupal.org/user/3540616)
Related to !292
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>We always have the SearchApiAiSearchBackend generate embeddings from the query value when Search API calls ::doSearch(). This can be an unnecessary extra LLM call to generate embeddings if we want to find related content/more like this. See <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/ai_related_content/-/work_items/3547620" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/ai_related_content/-/work_items/3547620</a></span>.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<ol>
<li>Add a check for getOption('search_by_vector_input') for example and use that instead of existing</li>
<li>Developers can then use setOption('search_by_vector_input') to prevent the doSearch generate embedding here*<br>
<div class="codeblock">
<pre><span style="color: #000000"><span style="color: #0000BB"><?php<br>$input </span><span style="color: #007700">= new </span><span style="color: #0000BB">EmbeddingsInput</span><span style="color: #007700">(</span><span style="color: #0000BB">$search_words</span><span style="color: #007700">);<br></span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #DD0000">'vector_input'</span><span style="color: #007700">] = </span><span style="color: #0000BB">$embedding_llm</span><span style="color: #007700">-></span><span style="color: #0000BB">embeddings</span><span style="color: #007700">(</span><span style="color: #0000BB">$input</span><span style="color: #007700">, </span><span style="color: #0000BB">$model_id</span><span style="color: #007700">)-></span><span style="color: #0000BB">getNormalized</span><span style="color: #007700">();<br></span><span style="color: #0000BB">?></span></span></pre></div>
</li>
</ol>
<p>* Developers are responsible for ensuring compatible vectors.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>NA</p>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>NA</p>
<h3 id="summary-api-changes">API changes</h3>
<p>NA</p>
<h3 id="summary-data-model-changes">Data model changes</h3>
<p>NA</p>
> Related issue: [Issue #3576426](https://www.drupal.org/node/3576426)
issue