Copied to clipboard

Flag this post as spam?

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


  • Dominik Merkle 9 posts 41 karma points
    Feb 09, 2015 @ 16:39
    Dominik Merkle
    1

    examine search criteria with wildcards

    Hi,

    I try to create a search criteria with wildcards for an autocomplete search.

    How can I use wildcard search if I make my own search criteria like this:

    var criteria = ExamineManager.Instance
    .SearchProviderCollection["ExternalSearcher"]
    .CreateSearchCriteria();

    string[] dynquery = new string[] { query };
    if (multipleGroupedOr)
    {
    dynquery = query.Split(multipleGroupedOrSeparator);
    }

    var crawl = criteria.GroupedOr(fieldnames, dynquery)
    .Not()
    .Field("umbracoNaviHide", "1")
    .Not()
    .Field("nodeTypeAlias", "Image")
    .Compile();

    ISearchResults SearchResults = ExamineManager.Instance
    .SearchProviderCollection["ExternalSearcher"]
    .Search(crawl);

     

    MultipleCharacterWildcard() on dynquery doesn't work.

    var crawl = criteria.GroupedOr(fieldnames, dynquery.MultipleCharacterWildcard())
    .Not()
    .Field("umbracoNaviHide", "1")
    .Not()
    .Field("nodeTypeAlias", "Image")
    .Compile();

     

    Thanks for any help!

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Feb 10, 2015 @ 11:39
    Ismail Mayat
    100

    dynquery is array string right? The multiplecharacterwildcard is extension for string which will tag * into end of term. So you could replace your grouped or with a loop and for each term wilcard it.  What I usually have is using gathering node data all my fields munged into one field and then i can search on that.  Are you currently getting a code compile error or is it all running but no search results coming back?  If no saerch results can you do criteria.ToString() and paste back the generated query.

    Regards


    Ismail

  • Dominik Merkle 9 posts 41 karma points
    Feb 10, 2015 @ 16:31
    Dominik Merkle
    0

    Hi Ismail,

    i have change my code with a loop but If I use "MultipleCharacterWildcard()" on a string, Visual Studio show me the error "string does not contain a definition for MultipleCharacterWildcard". What's wrong?

    var criteria = ExamineManager.Instance
    .SearchProviderCollection["ExternalSearcher"]
    .CreateSearchCriteria();

    string[] dynquery = new string[] { query };
    if (multipleGroupedOr)
    {
    dynquery = query.Split(multipleGroupedOrSeparator);
    }

    Examine.SearchCriteria.IBooleanOperation crawl = null;

    foreach (var word in dynquery)
    {
    if (crawl == null)
    {
    crawl = criteria.GroupedOr(fieldnames, word.MultipleCharacterWildcard());
    }
    else
    {
    crawl = crawl.Or().GroupedOr(fieldnames, word);
    }
    }

    crawl = crawl
    .Not()
    .Field("umbracoNaviHide", "1")
    .Not()
    .Field("nodeTypeAlias", "Image");


    ISearchResults SearchResults = ExamineManager.Instance
    .SearchProviderCollection["ExternalSearcher"]
    .Search(crawl.Compile());

    Regards
    Dominik

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Feb 10, 2015 @ 17:21
    Ismail Mayat
    0

    Dominik,

    You maybe missing a using statement is in one of these

    using Examine;
        using Examine.LuceneEngine;
        using Examine.LuceneEngine.SearchCriteria;
        using Examine.SearchCriteria;

     

    Regards

    Ismail

     

  • Dominik Merkle 9 posts 41 karma points
    Feb 10, 2015 @ 17:31
    Dominik Merkle
    0

    That's it.

    using Examine.LuceneEngine;
    using Examine.LuceneEngine.SearchCriteria;
    

    are missed.

    Thank you.

  • Dominik Merkle 9 posts 41 karma points
    Feb 10, 2015 @ 18:13
    Dominik Merkle
    0

    Hi Ismail,

    the wildcard and the autocomplete works. But if I search for a longtail for example "search term" there is no result. This is my code:

    var criteria = ExamineManager.Instance
                    .SearchProviderCollection["ExternalSearcher"]
                    .CreateSearchCriteria();
    
    
    
                string[] dynquery = new string[] { query };
                if (multipleGroupedOr)
                {
                    dynquery = query.Split(multipleGroupedOrSeparator);
                }
    
                Examine.SearchCriteria.IBooleanOperation crawl = null;
    
                foreach (var word in dynquery)
                {
                    if (crawl == null)
                    {
                        crawl = criteria.GroupedOr(fieldnames, word.MultipleCharacterWildcard()); 
                    } 
                    else
                    {
                        crawl = crawl.Or().GroupedOr(fieldnames, word.MultipleCharacterWildcard()); 
                    }
                }
    
                crawl = crawl
                    .Not()
                    .Field("umbracoNaviHide", "1")
                    .Not()
                    .Field("nodeTypeAlias", "Image");
    
    
                ISearchResults SearchResults = ExamineManager.Instance
                    .SearchProviderCollection["ExternalSearcher"]
                    .Search(crawl.Compile());
    

    Any idea? Thanks

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Feb 10, 2015 @ 18:32
    Ismail Mayat
    0

    Do criteria.ToString() to see the generated query that will give you more information as to what is going on.

    Regards

    Ismail

  • Dominik Merkle 9 posts 41 karma points
    Feb 20, 2015 @ 13:17
    Dominik Merkle
    0

    Hi Ismail,

    thanks for your help. To see the generated query helps a lot.

    Regards Dominik

Please Sign in or register to post replies

Write your reply to:

Draft