Restrict AI search content via context

Created on 19 September 2024, 1 day ago
Updated 20 September 2024, about 11 hours ago

Problem/Motivation

I have private groups using the group module (group version 2 at the moment).
I want to use AI search but only for items in that group or owned by that person doing the search. So the contexts might be group and user. I could also see a context for role.

Is there a way to do this.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ’¬ Support request
Status

Closed: works as designed

Version

1.0

Component

AI Search

Created by

πŸ‡ΊπŸ‡ΈUnited States SocialNicheGuru

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @SocialNicheGuru
  • πŸ‡¬πŸ‡§United Kingdom scott_euser

    Ultimately it's using search api as a backend and there is filtering on the metadata stored in zilliz/milvus supported. It attempts to convert the search api query conditions to milvus/zilliz filters so I guess you should be able to programmatically set context via some sort of search api query alter adding a condition as long as you have that e.g. group indexed as meta data (configure fields in search api).

  • πŸ‡©πŸ‡ͺGermany Marcus_Johansson

    scotts_eusers response is the correct one for performance.

    What you can do when you do the query is that you can set the option "search_api_bypass_access" to FALSE and it will start to iterate through the responses and make sure each of them is something that the user has access to via PHP, see here: https://git.drupalcode.org/project/ai/-/blob/1.0.x/modules/ai_search/src...

    It will try 10 loops in, until it gives up trying to find the amount of responses you want. It also gives back the real offset in the `real_offset` parameter and in `reason_for_finish` you can see if its finished because it looped through 10 pages of content or if it reached the end. The parameter `current_vector_score` also exists where you can see the lowest score of any row that we found.

    If performance is not off a concern, you have very few users doing this on a fairly small dataset, this solution would work as well and its just a toggle if you are getting a small dataset.

    Feel free to close this ticket if scotts and mine answer, answers your question.

  • Status changed to Closed: works as designed about 11 hours ago
  • πŸ‡ΊπŸ‡ΈUnited States SocialNicheGuru

    Thank you for the responses.

Production build 0.71.5 2024