Filter matches based on users joined groups (Query search in a list)


I’d like to allow the user to search only for matches inside his groups. I added the group id to the match label, something like this “label.GID:XXX-XXXX-XXXX-XXXX1”.

I’ve also come up with multiple possible implementations for this so far.

  1. Get the list of user groups and query each one. It’s simple but it’s not practical nor scalable. It means I have to send a query for each group the user is part of.
  2. Send the list of group ids in the bleve query. Something like this “+label.GID: [XXX-XXXX-XXXX-XXXX1,XXX-XXXX-XXXX-XXXX2,XXX-XXXX-XXXX-XXXX3,…]”. This should, hypothetically, return all the matches that have any of these group ids. I assume this would be better and more practical. However, I couldn’t make it work. Are there any suggestions to make it work or any other alternative solution?

This is for authoritative matches and I’m using Golang SDK.

Hi Ben,

You can make option 2 work if you do a slight modification to the query. The query engine doesn’t support that array syntax but you can restructure it to leverage regular expressions like this label.GID:/(XXX-XXXX-XXXX-XXXX1|XXX-XXXX-XXXX-XXXX2|XXX-XXXX-XXXX-XXXX3|...)/ and take advantage of the OR logic it already provides.


1 Like

That actually worked! Thank you, Flavio!