Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-5420

Driver Support for Search Sequential Pagination

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Hide

      Summary of necessary driver changes

      •  

      Commits for syncing spec/prose tests
      (and/or refer to an existing language POC if needed)

      •  

      Context for other referenced/linked tickets

      •  
      Show
      Summary of necessary driver changes   Commits for syncing spec/prose tests (and/or refer to an existing language POC if needed)   Context for other referenced/linked tickets  
    • None
    • Needed
    • Hide

      It is now possible to use the Buiders in C# to paginate the results of Atlas Search (https://www.mongodb.com/docs/atlas/atlas-search/paginate-results/)

      In particular:

      • `Builders<T>.Projection.MetaSearchSequenceToken` has been added and needs to be used to specify a property that will contain the search sequence token
      • This search sequence tokens of the returned values can then be used in pagination by setting it as `SearchAfter` or `SearchBefore` in `SearchOptions`.

      For instance

      ```
      var searchDefinition = Builders<Movie>.Search.Text(t => t.Title, "flower");
      var searchOptions = new SearchOptions<Movie>

      { IndexName = "default", Sort = Builders<Movie>.Sort.Ascending("year") }

      ;
      var projection = Builders<Movie>.Projection
      .Include(x => x.Title)
      .MetaSearchSequenceToken(x => x.PaginationToken);

      // Base search
      var baseSearchResults = GetCollection()
      .Aggregate()
      .Search(searchDefinition, searchOptions)
      .Project<Movie>(projection)
      .ToList();

      // SearchAfter (similar for SearchBefore)
      // We're searching after the 2nd result of the base search
      searchOptions.SearchAfter = baseSearchResults[1].PaginationToken;
      var searchAfterResults = GetCollection()
      .Aggregate()
      .Search(searchDefinition, searchOptions)
      .Project<Movie>(projection)
      .ToList();

      ```

      Show
      It is now possible to use the Buiders in C# to paginate the results of Atlas Search ( https://www.mongodb.com/docs/atlas/atlas-search/paginate-results/ ) In particular: `Builders<T>.Projection.MetaSearchSequenceToken` has been added and needs to be used to specify a property that will contain the search sequence token This search sequence tokens of the returned values can then be used in pagination by setting it as `SearchAfter` or `SearchBefore` in `SearchOptions`. For instance ``` var searchDefinition = Builders<Movie>.Search.Text(t => t.Title, "flower"); var searchOptions = new SearchOptions<Movie> { IndexName = "default", Sort = Builders<Movie>.Sort.Ascending("year") } ; var projection = Builders<Movie>.Projection .Include(x => x.Title) .MetaSearchSequenceToken(x => x.PaginationToken); // Base search var baseSearchResults = GetCollection() .Aggregate() .Search(searchDefinition, searchOptions) .Project<Movie>(projection) .ToList(); // SearchAfter (similar for SearchBefore) // We're searching after the 2nd result of the base search searchOptions.SearchAfter = baseSearchResults [1] .PaginationToken; var searchAfterResults = GetCollection() .Aggregate() .Search(searchDefinition, searchOptions) .Project<Movie>(projection) .ToList(); ```
    • None
    • None
    • None
    • None
    • None
    • None

      This ticket was split from DRIVERS-2681, please see that ticket for a detailed description.

            Assignee:
            ferdinando.papale@mongodb.com Ferdinando Papale
            Reporter:
            dbeng-pm-bot TPM Jira Automations Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              None
              None
              None
              None