Copied to clipboard

Flag this post as spam?

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


  • Marky 26 posts 65 karma points
    Nov 19, 2018 @ 10:17
    Marky
    0

    How to create Examine AutoComplete ?

    Hi, Good day!

    I would like a autocomplete function with Examine, which should work in a way that when I write "What is" it suggests

    "What is Piering " "What is soil testing" "What is roof sarking?"

    But what I've done is when I write "What is" it suggests all my posts that starts the word "What". See screenshot below.

    enter image description here

    Here is my code;

    [System.Web.Http.HttpPost]
    public List<Article> GetArticles(SearchArticleModel model)
    {
        var result = new List<Article>();
    
        if (!string.IsNullOrEmpty(model.Article))
        {
            var searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
            var searchCriteria = searcher.CreateSearchCriteria();
    
            // Find posts that contain our search text in either nodeName or title
            var searchQuery = searchCriteria.Field("nodeName", model.Article.Boost(8)).Or().Field("title", model.Article.Boost(5)).Compile();
    
            var searchResults = searcher.Search(searchQuery);
    
            foreach (var searchResult in searchResults)
            {
                var articles = new Article()
                {
                    Id = Convert.ToInt32(searchResult.Id),
                    Name = searchResult.Fields["title"],
                };
    
                articles.Url = articles.Id.TypedContent().Url ?? string.Empty;
    
                result.Add(articles);
            }
    
            return result;
        }
    
        return result;
    }
    

    Did I miss something?

    Any ideas or snippet

    Thanks,

    Marky

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Nov 19, 2018 @ 10:55
    Ismail Mayat
    0

    Marky,

    Can you write out the generated query I suspect the word 'is' is being stripped out as it is a stop word and you are using standard analyser.

    Regards

    Ismail

  • Marky 26 posts 65 karma points
    Nov 20, 2018 @ 03:26
    Marky
    0

    Hi Ismail,

    Thanks for your response.

    I am new in Umbraco, can you tell me how I can generate the query?

    Thanks,

    Marky

  • Marky 26 posts 65 karma points
    Nov 20, 2018 @ 05:21
    Marky
    0

    Hi Ismail,

    It might be the query?

    { SearchIndexType: , LuceneQuery: nodeName:what^8.0 title:what^5.0 }
    

    Thanks,

    Marky

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Nov 20, 2018 @ 08:41
    Ismail Mayat
    0

    you can see its stripping stop word "is" proof of this can be seen by using luke see image below:

    enter image description here

    I have done auto complete before but matching on single words, it was a combination of building a spellchecker index then doing the auto complete search on that. See on how to build spellchecker index http://blog.aabech.no/archive/building-a-spell-checker-for-search-in-umbraco/ you then have to create an autocomplete analyser that creates ngrams and you then search on that index. I used this stackoverflow post to get to that point https://stackoverflow.com/questions/120180/how-to-do-query-auto-completion-suggestions-in-lucene specifically this part which is c# port of some java code https://stackoverflow.com/a/9183416/719625

  • Marky 26 posts 65 karma points
    Nov 20, 2018 @ 09:02
    Marky
    0

    Hi Ismail,

    Thanks for your help, I will look into it.

    Regards,

    Marky

  • Marky 26 posts 65 karma points
    Jan 03, 2019 @ 03:54
    Marky
    0

    Hi Ismail,

    Here is what I've done, I add MultipleCharacterWildcard() because I read in your post regarding this extension. Link.

    // Find posts that contain our search text in title
    searchCriteria.NodeTypeAlias("StandardContent").And().Field("title", model.Article.MultipleCharacterWildcard()).Compile();
    

    Here is the update query

    { SearchIndexType: , LuceneQuery: +__NodeTypeAlias:standardcontent +title:what is* }
    

    But I got no results.

    []
    

    But here is the data that suppose to be displayed.

    What is Piering?
    What is soil testing?
    What is roof sarking?
    

    But still no luck, and don't know what's the next step.

    Thanks

    Marky

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jan 03, 2019 @ 10:06
    Ismail Mayat
    0

    Marky,

    Its not wildcard issue, did you take a look at my previous post with links on how to implement autocomplete? Also I only got it working single word.

    Regards

    Ismail

  • Marky 26 posts 65 karma points
    Jan 04, 2019 @ 01:44
    Marky
    0

    Hi Ismail,

    Thanks for your reply.

    I haven't read your post regarding on how to implement autocomplete, can you give the link? I really need help for this, since I'm new in Umbraco.

    Can you give me some ideas or what is the exact query to get the whole phrase, because as I read in other blogs that when *symbol is in the last it means, it will show all post that starts whatever you've enter on the search box. e.g. title:foo *

    I'm stuck on this.

    Thanks,

    Marky

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jan 04, 2019 @ 08:59
  • Marky 26 posts 65 karma points
    Jan 05, 2019 @ 03:19
    Marky
    0

    Ohh, Okay.

    This can't be done by using only Examine Search?

    Thanks,

    Marky

  • Marky 26 posts 65 karma points
    Jan 08, 2019 @ 06:48
    Marky
    0

    Hey Ismail,

    Last question, can you tell me where I can create this spellchecker public class SpellCheckIndexer : BaseUmbracoIndexer. I am really new in Umbraco, and I don't know where I can create this stuff.

    Thanks in advance,

    Marky

Please Sign in or register to post replies

Write your reply to:

Draft