Sitecore 8.1 | Don't search for custom Lucene stop words

I am using full text search solution for my website using Lucene. The goal is to search the content of all sitecore elements that have any search word.

I was able to do this using a predicate search:

var predicate = PredicateBuilder.True<SearchResultItem>();
var searchTerms = search.Split(' ');

predicate = predicate.Or(item => item.Content.Contains(search)).Boost(3);

foreach (var word in searchTerms)
{
 predicate = predicate.Or(item => item.Content.Contains(word)).Boost(1);
}

var allItems = Context.GetQueryable<SearchResultItem>().Where(predicate);

      

However, when I search for certain words, I have the error "Received Lucene query contains too many sentences."

To solve this error, I created a stopwords.txt file with these words, placed it at [FULL_PATH_TO_SITECORE_ROOT_FOLDER] \ Data \ indexes \ and changed the Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config file to:

<param desc="defaultAnalyzer" type="Sitecore.ContentSearch.LuceneProvider.Analyzers.DefaultPerFieldAnalyzer, Sitecore.ContentSearch.LuceneProvider">
  <param desc="defaultAnalyzer" type="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net">
    <param hint="version">Lucene_30</param>
      <param desc="stopWords" type="System.IO.FileInfo, mscorlib">
      <param hint="fileName">[FULL_PATH_TO_SITECORE_ROOT_FOLDER]\Data\indexes\stopwords.txt</param>
      </param>
  </param>
</param>

      

I stopped using the "Lucene query that was generated contains too many sentences", but from my understanding, when I set a stopword in the stopword.txt file, lucene should not look for that word in the content of the elements.

This means that when I search for "London holiday" I should return the same results as "London holiday".

However, this does not happen. When I search for "London holidays" you get a lot more results, including items where there is no "London" nor the word "holiday" but the word "in" exists.

Can someone help me figure out what I managed to avoid?

Thanks in advance.

+3


source to share





All Articles