Recursive retrieval using the supported grouping may still need recursion
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3549911. --> Reported by: [scott_euser](https://www.drupal.org/user/3267594) Related to !30 !8 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>In <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/ai/issues/3526390" title="Status: Closed (fixed)">#3526390: Improve the AI Search recursive retrieval of a specific quantity of results</a></span> we added support for grouping which we take advantage of in <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/ai_vdb_provider_milvus/issues/3526393" title="Status: Closed (fixed)">#3526393: Make use of Milvus' Grouping functionality</a></span>. However, Milvus Grouping makes the set quantity retrieval much better, but it is not guarenteed. E.g. Milvus is unaware of entity_access and therefore grouped results found may need to be subsequently excluded. So maybe the grouping needs to just be part of the doSearchWithIteration() method rather than instead of, and in most cases it will retrieve all results in first attempt</p> <h4 id="summary-steps-reproduce">Steps to reproduce (required for bugs, but not feature requests)</h4> <ol> <li>Milvus index attempt to retrieve specific number of results</li> <li>Content mixed published and unpublished</li> </ol> <p>So its a bit tricky but essentially you have to have a scenario where you want to e.g. find 3 relevance items from Milvus (which <em>can</em> use Grouping if you started a new index on 2.x), and of those 3, maybe 1 is unpublished. So you'd then get back 2 items as anonymous user because the checkEntityAccess() call would fail one of them. In the new scenario within the MR the checkEntityAccess() would fail 1, and so the limit in the doSearchWithIteration() wouldn't be hit, and it would have another pass at retrieving more entities from Milvus, eventually getting to the 3 (assuming there would have been more candidates beyond the first 3).</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Make search with grouping part of the iteration</p> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <p>MR</p>
issue