Copied to clipboard

Flag this post as spam?

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


  • Tim Brooks 27 posts 79 karma points
    Jun 19, 2015 @ 18:19
    Tim Brooks
    1

    Umbraco.TypedSearch() returns different results that using the lucene searcher on some environments

    On my development box using TypedSearch seems to work fine. But on our staging and other peoples dev I'm not getting the same results. If I switch over and use the Lucene searcher it works fine across all environments.

    Since it seems to be an environment issue and not code, I've double and triple checked that the pages are published by doing both a document publish and republish the entire site. I've tried deleting the Umbraco.config cache file and I've visually inspected it to confirm the documents in question actually exist. Knowing that TypedSearch () will return an IPublishedContent and those objects come from this same cache I would guess that it should return results.

    Then of course the really weird part is that is does work on my development machine, but not staging or other dev machines. I don't know what I did differently to have mine working.

    My easy and obvious work around would be to not use TypedSearch() and just use the lucene searcher to get the nodeIds I need then convert them to IPublishedContent myself. But I'd love to use the TypedSearch and skip that steep if possible, so I figured I'd post this and see if there are any suggestions on how to get it working.

    I will include a code example although since it does work in my dev, I don't know if this is a code issue.

      public ISearchCriteria ArticleSearchProvider()
            {
                var searcher = ExamineManager.Instance.SearchProviderCollection["ArticleSearcher"];
                return searcher.CreateSearchCriteria("content", BooleanOperation.Or);
            }
    
    public IEnumerable<ArticleListItemViewModel> SearchFeaturedArticles(string featuredAreaId, int count)
            {
                var query = ArticleSearchProvider()
                    .Field("featuredArea", featuredAreaId)
                    .Compile();
    
    
                var contentResults = _uHelper.TypedSearch(query).OrderByDescending(x => x.GetPropertyValue<DateTime>("publishDateOverride")); //only need one before casting into an articleviewmodel
                return GetArticleListItems(contentResults, 0, count);
            }
    

    I have just discovered its now working on one other development environment. But still failing on staging and other peoples. The two that work are the two of us who are developing the most on this project. I feel like I'm missing some order of events, for example maybe I need to do a regular publish at the top level of the content, then republish entire site, then rebuild the index. I'm going to start to experiment with that now. Any ideas are appreciated!

  • Tim Brooks 27 posts 79 karma points
    Jun 20, 2015 @ 00:34
    Tim Brooks
    0

    This site has well over 20K pages. I was under the impression that publish entire site would take all published content and put it into the cache. What I found was that if I hit publish on the root node and publish all the children the content is starting to show up. I did it a couple times throughout the day because the back office session will timeout while its still running. This isn't how I understood umbraco's behavior but I'm happy something has worked.

  • Doron Uziel 23 posts 93 karma points
    Jun 20, 2015 @ 17:11
    Doron Uziel
    0

    Could it be that your dev and staging env are not using the same default SearchProvider?

    If no other search provider is stated, then the TypedSearch uses the Examine.ExamineManager.Instance.DefaultSearchProvider, which is defined in: ~/config/ExamineSettings.config

    If this is not the case, you might try to compare the ExamineSettings.config and the ExamineIndex.config on your dev env with your staging one.

    One last step you seem to have missed is rebuilding you index (under developer section - Examine tab).

  • Tim Brooks 27 posts 79 karma points
    Jun 22, 2015 @ 17:23
    Tim Brooks
    0

    What I found to be the solution was to do a regular publish at the top level and I told it to published all child pages and even unpublished content. I would normally have believed this step was unnecessary. The database hold the information on what is published and when we deployed to staging we copied over the database.

    Either way it seems to be working now after the publish ran for a few hours. I'd still love to understand why this is necessary, but either way it works.

  • Doron Uziel 23 posts 93 karma points
    Jun 22, 2015 @ 19:28
    Doron Uziel
    2

    Just so you would know, publishing all content is not necessary. Next time go to the dev section and on the examine tab rebuild all indexes. It should take no more than a few minutes.

  • Tim Brooks 27 posts 79 karma points
    Jun 23, 2015 @ 00:53
    Tim Brooks
    0

    It wasn't in my original post but I tried rebuilding the index many times. When I used the searcher tool in the dev section I could find the content I expected. I agree with your understanding on how umbraco works. That a big reason why I never thought that doing the publish of all the content even mattered. But in this case, it did matter. And it had to complete, which took a couple of hours. I had actually done a publish before that but I don't think it ever completed.

  • Tim Brooks 27 posts 79 karma points
    Jun 23, 2015 @ 00:54
    Tim Brooks
    0

    also, if the index wasn't properly built I wouldn't have seen no results with the typedSearch, but getting the expected results with the lucene searcher.

  • Tim Brooks 27 posts 79 karma points
    Aug 18, 2015 @ 17:38
    Tim Brooks
    1

    This mystery has been solved. To recap the TypedSearch was not returning the expected results however the Lucene Searcher would return the correct results using the exact same query. Even though I was using a custom index for the search since I was using TypedSearch, it depends on the ExternalIndex. Rebuilt the external index and they both returned the same results.

Please Sign in or register to post replies

Write your reply to:

Draft