Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-38560

$graphLookup doesn't support search within specific field(like SQL based grammar of 'select')

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • Query Optimization

      As designed, $graphLookup is only capable of traversing a graph recursively, that is, by performing repeated queries on the "connectToField" value. However, if documents are huge because of many other fields that are not important(want to be ignored) for current graphlookup search, this will lead to the search exceeding the maximum memory usage. Leverage disk during the search will make bad performance.   $graphLookup should support an option that accepts a select within fields(very similar to  $project.), and this could be applied at each stage of the breadth-first search.  

      For example, consider a set of flight data, where each document represents a flight between two cities:

       

      { from: '1', to: '2' , oi: 'hugeJsonString1' }
      { from: '2', to: '3', oi: 'hugeJsonString1' }
      { from: '4', to: '5',  oi: 'hugeJsonString1' }
      ...

       

      If a user wishes to figure out all cities they can fly to from New York within two stops, but he doesn't care about the 'oi' part, they could add a 'project' keyword to exclude it during each stage of graphlookup search, like below: 

       

      {$graphLookup: {| |from: 'flights',| |project: \{'oi': 0}

      ,

      connectToField: 'from',
      connectFromFIeld: 'to',
      as: 'destinations'
      }}

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            tyin Yin Ting
            Votes:
            8 Vote for this issue
            Watchers:
            18 Start watching this issue

              Created:
              Updated: