Don't miss out Virtual Happy Hour today (April 26).
Try our conversational search powered by Generative AI!
AI OnAI Off
Don't miss out Virtual Happy Hour today (April 26).
Josh,
There's no built in way to do this AFAIK, but I'd recommend just creating a service class or extension method to access SearchClient.Instance.Search<T> with the FilterOnCurrentSite() extension already added. Then, you can re-use that code anywhere you need to make a search with IClient. Sometimes we'll place all our queries into a SearchManager class and then have a single private generic method in there where we set some base filters, and then each method might add additional filters for what it needs.
Personally, I'm a fan of having things like this be easily visible in the code since that's less "magic", but there's probably also a way to use StructureMap / DI to make this happen globally if you really wanted.
Hope this helps,
/Matt
I apologize if this has been answered already but i can't seem to locate the answer.
I am looking for a way that on every time we do a search, we apply a filter on every request. So by example, i want to filter results based on Site. Is there a way that instead of using .FilterOnCurrentSite() on every single query we have, is there a way to do this automatically on every query?
Thanks in advance.