Copied to clipboard

Flag this post as spam?

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


  • Dominik Pöhacker 8 posts 98 karma points
    May 03, 2023 @ 15:18
    Dominik Pöhacker
    0

    Examine search doesn't return results in production environment when additional field is querying

    Hi!

    I created an examine component which is adding a field to the index. The field is a searchPath filled with the path field values without comma like

    path: -1,1059,1122,1125

    searchPath: -1 1059 1122 1125

    The way to go i found to get all child nodes from its parent node. I also created a composer which automatically appends the examine component.

    Sometimes I want to query the searchPath field as well when a button is clicked. The implementation was quite easy and everything work as I expected. But it doesn't work in production environment and I don't know why. I rebuilded the indexes, cleared memory and database caches. Nothing helped me. But the searchPath field has been added and I can query this field in Examine Management as well.

    Here my query:

                            var searcher = index.GetSearcher();
    
                            // Node types only
                            var nodeTypeAlias = new[] {
                                "articleContentPage"
                            };
                            // Search fields only
                            var fieldsToSearch = new[] {
                                "nodeName_" + currentCulture,
                                "modules_" + currentCulture,
                                "hashtagLabels_" + currentCulture
                            };
    
                            var query = searcher.CreateQuery(IndexTypes.Content)
                                                            .GroupedOr(new[] { "__NodeTypeAlias" }, nodeTypeAlias)
                                                            .And()
                                                            .GroupedOr(fieldsToSearch, "\"" + searchTerm + "\"")
                                                            .Not().Field("umbracoNaviHide_" + currentCulture, 1.ToString());
    
                            // If searching only in specific article category
                            if (!string.IsNullOrEmpty(Request.QueryString["categoryId"]))
                            {
                                query.And().Field("searchPath", Request.QueryString["categoryId"].ToString());
                            }
    
                            var results = Current.PublishedContentQuery.Search(query);
    

    I also tried with the native query:

    var query = searcher.CreateQuery().NativeQuery("+(__NodeTypeAlias:articlecontentpage) +(nodeName_en-us:wiki modules_en-us:wiki hashtagLabels_en-us:wiki) -umbracoNaviHide_en-us:1 +searchPath:1125");
    

    I get results in Examine Management with exact this query above.

    On localhost everything works great. On production i don't get results if I add the searchPath field to my query. Without the field it works.

    Application is running in MS Azure Cloud.

    Had anyone similar problem?

  • Dominik Pöhacker 8 posts 98 karma points
    May 04, 2023 @ 10:19
    Dominik Pöhacker
    100

    Fixed it acordding this thread:

    https://our.umbraco.com/Documentation/Fundamentals/Setup/Server-Setup/azure-web-apps#recommended-configuration

    You need to add these appSettings for Azure Web Apps

    <add
        key="Umbraco.Core.MainDom.Lock"
        value="SqlMainDomLock" />
    <add
        key="Umbraco.Core.LocalTempStorage"
        value="EnvironmentTemp" />
    <add
        key="Umbraco.Examine.LuceneDirectoryFactory"
        value="Examine.LuceneEngine.Directories.SyncTempEnvDirectoryFactory, Examine" />
    
Please Sign in or register to post replies

Write your reply to:

Draft