22 May 2015

Stop Words with Custom Search Analyzer in Sitecore 7

As we know, at least in Lucene.NET 3.x.x version, the "stop words" are hand coded in this class "Lucene.Net.Analysis.StopAnalyzer". It does making the customizing the stop words a bit of tricky, especially for specific index since for the most of cases, you only need to customize one of the custom index to suit clients need. Here is a way how we can achieve that.

By default, Sitecore use "Lucene.Net.Analysis.Standard.StandardAnalyzer" and you can find it in wbe.config.(/configuration/sitecore/search/analyzer)


We create a new custom Analyzer inherit from "standardAnalyzer" and override the constructor. Here is the place I assign my own custom stop words to "STOP_WORDS_SET"
public class CustomAnalyzer : Lucene.Net.Analysis.Standard.StandardAnalyzer
{
        private static ISet STOP_WORDS_SET = GetStopWords();//{{"by","by"}}; <-- Makes "by" a 
       
        public CustomAnalyzer()
            : base(Lucene.Net.Util.Version.LUCENE_30, STOP_WORDS_SET)
        {      
        }

        private static ISet GetStopWords()
        {
            string[] strArray = GetWords();
            CharArraySet set = new CharArraySet(strArray.Length, false);
            set.AddAll((IEnumerable)strArray);
            return (ISet)CharArraySet.UnmodifiableSet(set);
        }
}

After, under "/configuration/sitecore/search/analyzer" in web.config, we wire the custom analyzer as below,

      
        Lucene_30
      

Don't forget to register it from you custom index file





Done!!!

34 comments:

  1. wonderful information, I had come to know about your blog from my friend nandu , hyderabad,i have read atleast 7 posts of yours by now, and let me tell you, your website gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you! Thanks a ton once again,
    Regards, sitecore training in hyderabad

    ReplyDelete
  2. I would like to say that this blog really convinced me to do it! Thanks, very good post. custom strapback hats

    ReplyDelete
  3. We do custom patches, embroidered patches, printed patches, custom Velcro patches, clothing labels, PVC patches, custom leather patches, custom keychains, and other promotional products. Following is an overview of our products. Custom Iron On Patches

    ReplyDelete
  4. I am incapable of reading articles online very often, but I’m happy I did today. It is very well written, and your points are well-expressed. I request you warmly, please, don’t ever stop writing. handmade leather crossbody bag

    ReplyDelete
  5. Mmm.. great to be here in your article or post, whatever, I figure I ought to likewise buckle down for my own site like I see some great and refreshed working in your site. get more info

    ReplyDelete
  6. Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. custom made patches

    ReplyDelete
  7. I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often. Custom Embroidered Patches

    ReplyDelete
  8. I am happy to find this post Very useful for me, as it contains lot of information. I Always prefer to read The Quality and glad I found this thing in you post. Thanks Canada Visa for German Citizens

    ReplyDelete
  9. I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy. wiza do Kanady

    ReplyDelete
  10. Advantage however much as could be viewed as standard from on a gigantic level premium substances - you will find that individual for: https://vograce.com

    ReplyDelete
  11. You completed a few fine points there. I did a search on the subject and found nearly all persons will go along with with your blog. check this out

    ReplyDelete
  12. For many people this is important, so check out my profile: check this site

    ReplyDelete
  13. You have a real talent for writing unique content. I like how you think and the way you express your views in this article. I am impressed by your writing style a lot. Thanks for making my experience more beautiful. learn more

    ReplyDelete
  14. If you are looking for more information about flat rate locksmith Las Vegas check that right away. Інтэрнэт -віза ў Індыю

    ReplyDelete
  15. Wow, excellent post. I'd like to draft like this too - taking time and real hard work to make a great article. This post has encouraged me to write some posts that I am going to write soon. indiai vízum online

    ReplyDelete
  16. Thanks for picking out the time to discuss this, I feel great about it and love studying more on this topic. It is extremely helpful for me. Thanks for such a valuable help again. Indien Touristenvisum

    ReplyDelete
  17. Hey – decent blog, just looking around plenty of blogs, seems a really nice platform you are using. I’m currently using WordPress for some of my sites but looking to change one amongst these over to a platform similar to yours as a trial run. Anything in particular you’ll recommend about it?
    kanada visum online

    ReplyDelete
  18. Thank you for the update, very nice site.. custom patches online

    ReplyDelete
  19. Interesting topic for a blog. I have been searching the Internet for fun and came upon your website. Fabulous post. Thanks a ton for sharing your knowledge! It is great to see that some people still put in an effort into managing their websites. I'll be sure to check back again real soon. check this link

    ReplyDelete
  20. I wrote about a similar issue, I give you the link to my site. visit this site

    ReplyDelete
  21. We have sell some products of different custom boxes.it is very useful and very low price please visits this site thanks and please share this post with your friends. excellentcustomclothing

    ReplyDelete
  22. Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. excellentcustomclothing.com

    ReplyDelete
  23. Wow, cool post. I’d like to write like this too – taking time and real hard work to make a great article… but I put things off too much and never seem to get started. Thanks though. website

    ReplyDelete
  24. I just thought it may be an idea to post incase anyone else was having problems researching but I am a little unsure if I am allowed to put names and addresses on here. check this site

    ReplyDelete
  25. Welcome to the party of my life here you will learn everything about me. custom embroidered keychains

    ReplyDelete
  26. Thanks so much for this information. I have to let you know I concur on several of the points you make here and others may require some further review, but I can see your viewpoint. website

    ReplyDelete
  27. I can give you the address Here you will learn how to do it correctly. Read and write something good. custom pvc patches

    ReplyDelete
  28. Thank you so much as you have been willing to share information with us. We will forever admire all you have done here because you have made my work as easy as ABC visit here

    ReplyDelete
  29. This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article. website

    ReplyDelete
  30. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. check this link

    ReplyDelete
  31. Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon! houston patches

    ReplyDelete
  32. So it is interesting and very good written and see what they think about other people. visit this site

    ReplyDelete

WFFM Web form for marketer fail to submit in Sitecore

I have setup a standard form using WFFM in Sitecore 8.2. It always fail when submit. Error as below, Error: Exception: System.Data.DataE...