2

We are using Azure search. This is a website search. End user enters the keyword and the pages where it is present in the content, are returned as search results.

The functionality works fine when the page is browsed in the English version and the keyword is in English, but Thai-Thai is not working.

Is there any particular way to index the content for a multi-lingual site.

string index = string.Format("sitecore_{0}_index", Context.Database.Name.ToLower());

using (var context = ContentSearchManager.GetIndex(index).CreateSearchContext())
{
  IQueryable<SearchResultItem> query = context.GetQueryable<SearchResultItem>()
              .Where(x => x.Paths.Contains(ID.Parse(SitecoreUtility.GetHomeItem().ID)) &&
              x.Content.Contains(keywords) && x.Language == Sitecore.Context.Language.Name);

  if (query != null && query.Count() > 0)
  {
     //process search result
  }
}

I have followed the solution here to build the _content field value.

The if condition fails for Thai search.

So, I modified it and found out that it actually returns no results for this:

IQueryable<SearchResultItem> querytest = context.GetQueryable<SearchResultItem>()
                  .Where(x => x.Paths.Contains(ID.Parse(SitecoreUtility.GetHomeItem().ID)) &&
                x.Language == Sitecore.Context.Language.Name);

I'm only searching for page items that are under the "Home" item. Does it mean, the Thai page items werent indexed.

Using Sitecore 8.2 version 3

  • Please try checking in whole content tree instead of a particulat node. There is a possibility that in that node Thai language items are not present. – arun tiwari Feb 5 '18 at 11:11
  • Downvoted for abandoned post – Mark Cassidy Sep 4 '18 at 12:02
1

Try this query

IQueryable<SearchResultItem> querytest = context.GetQueryable<SearchResultItem>(new CultureExecutionContext(Sitecore.Context.Language.CultureInfo))
              .Where(x => x.Paths.Contains(ID.Parse(SitecoreUtility.GetHomeItem().ID)));

Instead of your current query

IQueryable<SearchResultItem> querytest = context.GetQueryable<SearchResultItem>()
              .Where(x => x.Paths.Contains(ID.Parse(SitecoreUtility.GetHomeItem().ID)) &&
            x.Language == Sitecore.Context.Language.Name);

See if you get any results.

It's also worth looking into your search index to see what documents are in there, this blog should help you get startedf - https://www.geekhive.com/buzz/post/2017/05/viewing-indexed-azure-search-content-sitecore/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.