Thanks for your feedback. I have only used an example using Examine, and still trying to separate the two languages. Could you give me more details of what I need to set up / configure? Could it be an idea and use Dictionary to set up two languages - "no" and "en" (with the Dictionary name "language")?
Create different indexes for each language, in the examine config you can setup start node as well.
Also the other advantage of this is you can setup different language specific analysers for different languages. So we had to do this recently for german so our config looks like:
And I could need some help to get modifying the up-to-date search code (code abowe, or is it old?) to my Umbraco 7.5 website, so it filter out only searching site for the related language.
Have you added root node IDs and created separate indexes for each site? If so then you can just get that language searcher. So if you have created NoSearcher then when you get that searcher in code it will only search content in No site.
var searcher = ExamineManager.Instance.collections["someindexsearcherhere] something like that I'm on move ATM so cannot get to laptop have a look at examine docs.
var searcher = ExamineManager.Instance.SearchProviderCollection["External_NoIndexSet"];
var searchCriteria = searcher.CreateSearchCriteria(UmbracoExamine.IndexTypes.Content);
where External-no-IndexSet is set in ExamineIndex.config?
I just kind of made that code up you will need to figure out which language instance you are in. You could do that by getting the region set for the site using culture and hostnames.
var searchResults = searcher.Search(query).Where(r => r["__IndexType"] == "content").ToList();
You do not need that extra linq bit. One its already covered when you create the searcher by passing in IndexTypes.Content. Second it is in efficient you should when working with examine do further filtering using linq just use examine.
Razor search in a multilingual site
I have now prepared the site for two language versions:
listerfriluft.no < norwegian language
en.listerfriluft.no < english language
The code works, but searches are currently showing result from both language versions.
How can I separate search so they appear in only one language at the time?
I would assume that it is the line that must be changed to distinguish between the language versions / subdomains, but how?
Hi Tom,
In my case I created an index handler to add a space delimited copy of the path field to my External index. I named the new field pathSearch.
When I want to limit a search to a specific subset of nodes I add a clause to the search criteria using the pathSearch field.
Syntax may be a bit off as I don't have my code in front of me.
Just to clarify I'm not using this for different languages/hosts but if you have separate root nodes for each language this approach should work.
HTH Ver
So how du you create this index handler with name "pathSearch"?
Thanks for your feedback. I have only used an example using Examine, and still trying to separate the two languages. Could you give me more details of what I need to set up / configure? Could it be an idea and use Dictionary to set up two languages - "no" and "en" (with the Dictionary name "language")?
Tom,
Create different indexes for each language, in the examine config you can setup start node as well.
Also the other advantage of this is you can setup different language specific analysers for different languages. So we had to do this recently for german so our config looks like:
You will need to modify your search code slightly so depending on the language site you are in you use that searcher.
I DO NOT recommend putting different language content in the same index.
Regards
Ismail
I've made these in ExamineIndex.config, but I don't know how to use this (norwegian first, than english):
Is IndexParentId the Id value of Content "Hjem" (norwegian) and "Home" (english)?
And I could need some help to get modifying the up-to-date search code (code abowe, or is it old?) to my Umbraco 7.5 website, so it filter out only searching site for the related language.
Have you added root node IDs and created separate indexes for each site? If so then you can just get that language searcher. So if you have created NoSearcher then when you get that searcher in code it will only search content in No site.
Regards
Ismail
Tom,
To get it you would do
var searcher = ExamineManager.Instance.collections["someindexsearcherhere] something like that I'm on move ATM so cannot get to laptop have a look at examine docs.
Also make you create the searcher in config.
Sometning like this?
where External-no-IndexSet is set in ExamineIndex.config?
Still don't work, and what to do when english language (I realy need a complete multilingual search example for Umbraco 7.5)...
This taken straight from the docs:
In your examinesettings.config make sure you have entry for that searcher:
You will also need to add for the other languages. Then in your template code you can do
if(language="en"){var externalSearcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];}
I just kind of made that code up you will need to figure out which language instance you are in. You could do that by getting the region set for the site using culture and hostnames.
Regards
Ismail
Yes, this works even with Dictonary, the name of root node, or the id of root node.
The contents of the different languages are separated in search.
ExamineSettings.config (added)
ExamineIndex.config (added)
SearchResult.cshtml
Tom,
Glad you got it working. One thing the line:
You do not need that extra linq bit. One its already covered when you create the searcher by passing in IndexTypes.Content. Second it is in efficient you should when working with examine do further filtering using linq just use examine.
Regards
Ismail
Thanks. Doesn't have much experience with Linq, and wondered how the codes work. When I changed the line to
I got the same result, so this line is now used instead.
=========================================
Following up with continuing questions in a new thread:
https://our.umbraco.org/forum/extending-umbraco-and-using-the-api//80408-multilingual-alternate-canonical-and-301-and-ip-redirect
is working on a reply...