Copied to clipboard

Flag this post as spam?

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


  • AvihayBit 149 posts 303 karma points
    Jul 16, 2018 @ 15:11
    AvihayBit
    0

    Trying to search for every node that contains *all* the words in a searchString

    Hi, I use to search with C# Contains() for complicated search websites... But the poor performance makes me try to go through the examine road agin :) hopefully it would go better this time.

    When I want to search for every node that contains all the words in the searchString I usually us this code that woks great, but slow:

    string[] SearchTermList = searchString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        searchResults = searchResults.Where(x => SearchTermList.All(y=> x.Name.Contains(y) || 
                                                                        x.GetPropertyValue<string>("title").Contains(y)|| 
                                                                        Umbraco.TagQuery.GetTagsForProperty(x.Id,"author").Where(p => p.Text.Contains(y)).Any()||
                                                                        Umbraco.TagQuery.GetTagsForProperty(x.Id,"Subjects").Where(p => p.Text.Contains(y)).Any()||
                                                                        x.GetPropertyValue<string>("promo").Contains(y)||
                                                                        x.GetPropertyValue<string>("content").Contains(y)
                                                                    )
                                            );
    

    any Idea how to achive same result with the Umbraco examine search? if I use

    searchResults = lessonsBase.Search(searchString, true);
    

    it gives me every node that contains any of the words in the searchString - too many results...

    Thanks!

  • 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