I'm trying to search my content tree for a set of tags that are specific to each culture. The problem i'm encountering is that my current query does not automatically search for alias fields with the current culture. If i do explicitly search for an alias with an appended culture it finds the content.
var relatedArticleTags = Model.RelatedArticleTags?.ToArray() ?? new string[0];
if (ExamineManager.Instance.TryGetIndex(Constants.UmbracoIndexes.ExternalIndexName, out var index))
{
var results = index.GetSearcher().CreateQuery()
.NodeTypeAlias(Article.ModelTypeAlias)
.And().GroupedOr(new string[] { Model.GetProperty("tags").Alias }, relatedArticleTags)
.Not().Id(Model.Id).OrderBy(new SortableField("createDate", SortType.String))
.Execute();
foreach (var result in results)
{
var article = Umbraco.Content(result.Id);
relatedArticleItems.Add(article);
}
}
Is there a way for examine to automatically do searches on content by the current active culture?
Does examine search by culture?
I'm trying to search my content tree for a set of tags that are specific to each culture. The problem i'm encountering is that my current query does not automatically search for alias fields with the current culture. If i do explicitly search for an alias with an appended culture it finds the content.
Is there a way for examine to automatically do searches on content by the current active culture?
Hi Sorin,
You could pass the current culture to your search method. I believe you can get the current culture this way:
I'm currently passing in a string to each filter where i manually combine the fieldname and culture.
Or is there another way to actually pass the culture to Examine?
I'm not sure if there is another way of doing this, but if you need to search on multiple fields you can do something like this:
The example is found on: https://skrift.io/issues/examine-in-umbraco-8/
is working on a reply...