Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Morten Ørgaard 22 posts 61 karma points
    Sep 02, 2014 @ 11:50
    Morten Ørgaard
    0

    Umbraco external search

    Hi Guys

    I have a project where the word "Kommune" is written on several pages.

    The pages where "Kommune" is set, only shows up in my searchresult if I search for the exact word - "Kommune"

    If I search for ”kommune”, ”kom” or something like that, the pages will not show up in the search result.

    How do I get my search to be case insensitive and search for parts of words also?

    Best regards 

    Morten

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Sep 02, 2014 @ 12:11
    Jeroen Breuer
    0

    Hello,

    What kind of search are you using? This package has the best search results: http://our.umbraco.org/projects/website-utilities/ezsearch

    Jeroen

  • Morten Ørgaard 22 posts 61 karma points
    Sep 02, 2014 @ 12:46
    Morten Ørgaard
    0

    I'm using Umbraco Examine

    <add name="SiteIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"
    runAsync="true"
    supportUnpublished="false"
    supportProtected="true"
    interval="10"
    analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>   

    <add name="SiteSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
    analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net" enableLeadingWildcard="true" />

    <IndexSet SetName="SiteIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/Site/">
    <IndexAttributeFields>
    <add Name="id" />
    <add Name="nodeName"/>
    <add Name="nodeTypeAlias" />
    <add Name="parentID" />
    </IndexAttributeFields>
    <IndexUserFields>
    </IndexUserFields>
    <IncludeNodeTypes />
    <ExcludeNodeTypes />
    </IndexSet>

    var criteria = ExamineManager.Instance.SearchProviderCollection["SiteSearcher"].CreateSearchCriteria();
    var filter = criteria
    .GroupedOr(new string[] { "nodeName"
    , "columnOneContent" }, searchTerm)
    .Not()
    .Field("umbracoNaviHide", "1")
    .Compile();

    searchResults = ExamineManager.Instance.SearchProviderCollection["SiteSearcher"].Search(criteria);

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Sep 02, 2014 @ 12:51
    Jeroen Breuer
    0

    Hello,

    ezSearch is a wrapper around examine. I really recommend that you use it for searching because it works much easier.

    Jeroen

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Sep 02, 2014 @ 12:58
    Ismail Mayat
    100

    Morten,

    +1 on ezsearch, the reason why your search is not quite working is one you are using whitespace analyser this is case sensitive namely when stuff is indexed its not lowered cased unlike standard which will lower case everything, secondly your search term is not wildcard so it will not partial match. Use ezsearch its all done for you and it just works.  You can look at the code to see how its all put together so you understand examine better also i recommend having a read through my blog posts here http://thecogworks.co.uk/blog/posts/2012/november/examiness-hints-and-tips-from-the-trenches-part-1/ many of the things in ezsearch are taken from hints in these blog posts.

    Regards

    Ismail

  • Morten Ørgaard 22 posts 61 karma points
    Sep 02, 2014 @ 13:33
    Morten Ørgaard
    0

    I hear you both, and I'm thankful for your help. But I also would like to do it from scratch, så that I can do it myself and i the process, maybe learn a thing or two.:)

    I have changed my analyser to standard. But now only get one result when I search for "Kommune" or "kommune".

    Which wildcards can I use?

  • Morten Ørgaard 22 posts 61 karma points
    Sep 02, 2014 @ 13:43
    Morten Ørgaard
    0

    Ismali > By your comment I was able to find the solution.

    1) I changed the analyser to standard.

    2) I added ".ToLower().MultipleCharacterWildcard()" to the searchTerm in filter variable.

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Sep 02, 2014 @ 13:44
    Ismail Mayat
    0

    Morten,

    In your code where you have searchTerm change it to 

    searchTerm.MultipleWildCard() 

    You will also need reference to usingUmbracoExamine.SearchCriteria; although if you are using resharper it should wire that up for you.

    After you changed the analyser did you rebuild the index?

    Regards

    Ismail

  • Morten Ørgaard 22 posts 61 karma points
    Sep 02, 2014 @ 13:46
    Morten Ørgaard
    0

    Ohh, that was actually the third thing I did. But I didn't have that namespace, but found it in Examine.LuceneEngine.SearchCriteria :)

Please Sign in or register to post replies

Write your reply to:

Draft