filtering examine search results in current culture only
Hi,
I have a simple search in razor and a multilanguage website tree like below
CONTENT
- TR
--search
- EN
--search
all the content are in their own language tree and the culture is set accordingly. I want the sarch to show results only in the same language. How should I modify the below code?
Looks like you have a solution that works for you, but here's an alternate approach I took on a recent project that might be worth considering in the future:
filtering examine search results in current culture only
Hi,
I have a simple search in razor and a multilanguage website tree like below
CONTENT - TR --search - EN --search
all the content are in their own language tree and the culture is set accordingly. I want the sarch to show results only in the same language. How should I modify the below code?
Thanks in advance :)
I think the best way is to store your culture in the index. So you can use it in your search clause.
You can do this by hooking in to the GatheringNodeData event of examine.
A google on that will give a you a lot of examples.
Dave
Hi Dave,
thanks for the answer but I found an easier way to do it..
Hi Bora,
Looks like you have a solution that works for you, but here's an alternate approach I took on a recent project that might be worth considering in the future:
In ExamineIndex.config:
With the IndexParentId matching the root node of the culture.
In ExamineSettings.config:
And then something like this example function in an API controller (modify as needed to your use case):
It has the benefit of letting you not having to modify the C# code after launch if you add more cultures, instead only modifying the Examine configs.
Hope it helps :)
is working on a reply...