0

We are getting the wrong result returned.

for example, a search for the item named "alumni" returns the item "commencement-alumni-help" when no result should be returned.

SearchContext.GetQueryable<SearchResultItem>()
    .Filter(s => s.TemplateId == SpecificTemplateId &&
            s.Path.Contains("/Path/to/Website"))
    .Where(i => i.Name == "alumni")
    .GetResults();

I have a theory it might be related to tokenizing; however, item names shouldn't be an issue. Even sitecore's documentation indicates that you can directly search for item names.

  • just a thought, why don't you add another filter something like this s.Path.EndsWith("/alumni"). May be a slight performance impact but it may work in your case. – Gobinath Saminathan Jan 30 at 20:19
1

Item name (_name) field in lucene/solr is defined as text type, so it is stored as a tokenized value in search indices. So when you search using name, (query will be formed like _name:(alumni)) it will return all items which contains "alumni" in name.

By default, Name/_name is a tokenized field so the result you are getting is absolutely valid/expected.

| improve this answer | |
  • I couldn't quite find "_name" in the config file, but I can totally see that being the case. (it's happened before) – Adam Hess Jan 29 at 21:57
  • I am sure that you can edit the schema file in Solr to update the type.. But no idea in lucene – Gobinath Saminathan Jan 30 at 19:39

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.