0

In our application, I am trying to implement stopword for various language. We are having country wise core index. One of my search, I am fetching search item using Content, Headline and SearchKeyword fields. Below is my custom search result item model.

public class SiteSearchResultItem: SearchResultItem
{
       [IndexField("headline")]
       public string HeadLine { get; set; }

       [IndexField("searchkeywords")]
       public string SearchKeywords { get; set; }
}

Content maps to “Sitecore.ContentSearch.SearchTypes.SearchResultItem” Property. I am building filter using predicate builder as below.

predicate = predicate.Or(p => p.Content.Contains(searchParms.SearchTerm))
                .Or(p => p.Content.Equals(searchParms.SearchTerm))
                .Or(p => p.HeadLine.Contains(searchParms.SearchTerm).Boost(5f))
                .Or(p => p.HeadLine.Equals(searchParms.SearchTerm).Boost(5f))
                .Or(p => p.SearchKeywords.Contains(searchParms.SearchTerm))
                .Or(p => p.SearchKeywords.Equals(searchParms.SearchTerm));

I am testing stopword for Portuguese language. So, I have added a stopword “estávamos” in corresponding stopword_pt.txt file. While query through solr admin, it’s working fine. Below are the queries, I have tested.

In sitecore, I have create two item which has title and “menu_title” which points to headline in solr field.

Solr Admin Raw Query:

headline_t_pt:estávamos brazil => Providing no data

headline_t_pt:”estávamos brazil” => Providing only Item which has title brazil data

menu_title_t_pt:"estávamos brazil" => Providing only item which has menu title brazil.

Query which passed to solr:

(_content:(estávamos brazil) OR _content:("estávamos brazil") OR headline_t_pt:(estávamos brazil) OR headline_t_pt:("estávamos brazil")) AND _language:(pt-BR)

So, It’s working fine in solr Admin tool. But in my sitecore application, it’s not excluding those data.

And Also I need what are the fields will be in content property in solr sitecore. It's mapping to "_content" solr field?

  • Check the Search log files to see what the actual SOLR query is that Sitecore is sending over. – Richard Seal May 30 '17 at 14:07
  • Query passed: (_content:(estávamos brazil) OR _content:("estávamos brazil") OR headline_t_pt:(estávamos brazil) OR headline_t_pt:("estávamos brazil")) AND _language:(pt\-BR) – user3024615 May 31 '17 at 9:45
1

The _content field is a field which contains the content of ALL your fields. It is NOT language dependent and does not remove stopwords on the solr side- so remove the p.Content.Contains(searchParms.SearchTerm)) .Or(p => p.Content.Equals(searchParms.SearchTerm)

predicates.

| improve this answer | |

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.