Copied to clipboard

Flag this post as spam?

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


  • George Phillipson 108 posts 288 karma points
    Oct 25, 2019 @ 10:52
    George Phillipson
    0

    Examine not exact match search

    Hi

    How do you do a non-exact search using Examine?

    I currently have:

     if (ExamineManager.Instance.TryGetIndex("ExternalIndex", out var index))
                    {
                        var searcher = index.GetSearcher();
                        var results = searcher.CreateQuery("content").ManagedQuery(q).And().GroupedOr(new[] { "__NodeTypeAlias" }, "home", "parentContentPage", "childContentPage").Execute().ToList();
    
     // not relevant
                    }   
    

    But it only returns exact matches, if I have a query 'technology assets' I would like to try and search for 'technology' and 'assets' then order by score.

    I have seen loads of examples, but none for V8 as:

    var Searcher = ExamineManager.Instance.SearchProviderCollection[examineSearcherName];
    

    now returns IExamineManager does not contain a definition....

    Any help would be appreciated

    George

  • George Phillipson 108 posts 288 karma points
    Oct 25, 2019 @ 14:30
    George Phillipson
    0

    Worked it out, below is how I did it in case anyone ever needs this

    string[] words = q.Split(' ');
    
    
                    List<string> newQuery = new List<string>();
    
                    foreach (var word in words)
                    {
                        newQuery.Add(word);
                    }
    
                    var searcher = index.GetSearcher();
                    var results = searcher.CreateQuery("content").GroupedOr(new[] { "nodeName","pageTitle","pageDescription"}, newQuery.ToArray()).Execute().ToList();
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies