Copied to clipboard

Flag this post as spam?

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


  • Craig100 1136 posts 2523 karma points c-trib
    Jul 06, 2022 @ 22:16
    Craig100
    0

    Paged search with IQueryExecutor problem

    Umbraco V10.0.1

    I find in the following code, where I'm trying to search with IQueryExecutor to get paging, that the resultCount is correct but the searchResults are 0.

    The query performs correctly in Luke against the InternalIndex using the Standard Analyser. If I recode for an unmanaged query set (searchResults = umbIndex.Searcher.CreateQuery()........Excute()) then I can get a full list of results, just not paged.

        var indexName = Constants.UmbracoIndexes.InternalIndexName;
    
        // Get the index with error checking
        if (!_examineManager.TryGetIndex(indexName, out var index) || !(index is IUmbracoIndex umbIndex))
        {
          throw new InvalidOperationException(
            $"No index found by name {indexName} or is not of type {typeof(IUmbracoIndex)}");
        }       
    
    var query = umbIndex.Searcher.CreateQuery(IndexTypes.Content);
    
           var queryExecutor = query.ManagedQuery(searchTerm)
              .And().NodeTypeAlias("ThreeColumnPage")
              .And().Field("column2Content", searchTerm)
              .Not().Field("umbracoNaviHide", 1.ToString())
              .Not().Field("published", "n".ToString());
    
              searchResults = _publishedContentQuery.Search(
                queryExecutor,
                skip,
                pageSize,
              out resultCount);
    

    Resulting in this (missing links list)

    enter image description here

    (skip and pageSize are correct and has similar performance against the ExternalIndex ;) )

    Is IQueryExecutor still useable in V10+ ?

    I want to get paged resultsSets rather than pull all the results every time and page them every time for efficiency.

    Any advice would be appreciated.

    • Craig
  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Jul 06, 2022 @ 22:53
    Shannon Deminick
    1

    IQueryExecutor in Examine 3.0 hasn't changed. You can see all Examine changes for that release here https://github.com/Shazwazza/Examine/compare/dev...release/3.0

    So perhaps its a change within Umbraco for v10, not sure.

  • Craig100 1136 posts 2523 karma points c-trib
    Jul 07, 2022 @ 13:37
    Craig100
    0

    Turns out you were right......

    https://github.com/umbraco/Umbraco-CMS/issues/12551

    The workaround mentioned is to inject IPublishedSnapshotAccessor and use this:-

     _publishedSnapshotAccessor.TryGetPublishedSnapshot(out var publishedSnapshot);
    var queryResults = searchQuery.Execute(new QueryOptions(0, 12));
    var totalResults = queryResults.TotalItemCount;
    var publishedContentResults = queryResults.ToPublishedSearchResults(publishedSnapshot);
    
Please Sign in or register to post replies

Write your reply to:

Draft