[Solved] Search current culture
# help-with-umbraco
c
I'm trying to use a search I built for a V10 single language site in a multi-lingual site but having trouble adding the culture in. I have the culture, just can't find where to put it:
Copy code
var searchQuery = umbIndex.Searcher.CreateQuery(IndexTypes.Content)
            .NodeTypeAlias("generalPage")
            .And().Field("mainContent", searchTerm)
            .Not().Field("umbracoNaviHide", 1.ToString())
            .Not().Field("published", "n");
umbIndex is an IUmbracoIndex and it has a .GetCultureFields(Index, Culture) on it, but I doubt it's useful. I should just mention this is in a View with the following injections:-
Copy code
@inject IExamineManager _examineManager
@inject IPublishedSnapshotAccessor _publishedSnapshotAccessor
Any ideas appreciated.
d
Hi Craig! The culture is part of the fieldname. If you want to see exactly how that looks, I recommend you use the examine manager in the settings section in Umbraco and use the searchbar in the external index to find an example page. You can then check out all the indexed fields with their names. If I remember correctly, you append the ISO culture code to the fieldname with an underscore, so in your case, 'mainContent' would become 'mainContent_en-us'. But definitely check out the examine manager and see for yourself what your fieldnames look like:
c
Hi D! Thanks for that. I'd used Luke and it looked like it needed to be something like
+__NodeTypeAlias:generalpage +mainContent.items[0].text_en-gb:financial
, but that got me nothing in the back office. But as you say, using
+__NodeTypeAlias:generalpage +mainContent_en-gb:financial
gets results. So code is now like this and it works!
Copy code
string searchFieldWithCulture = "mainContent_" + culture;

var searchQuery = umbIndex.Searcher.CreateQuery(IndexTypes.Content)
    .NodeTypeAlias("generalPage")
    .And().Field(searchFieldWithCulture, searchTerm)
    .Not().Field("umbracoNaviHide", 1.ToString())
    .Not().Field("published", "n");
Thanks.
2 Views