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

Project array by text search predicate

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying, Text Search
    • Query Integration

      Suppose I create the following db/collection:

      > use articles
      > db.stores.insert( [ 
                   {_id : 1, arr : ['abc xyz', 'def']}, 
                   {_id : 2, arr : ['jadskf', 'ljh abc']}])
      > db.stores.createIndex({"arr" : "text"})
      

      I want to do text search over the arrays arr and obtain only the array elements that match the search.

      For instance,

      > db.stores.find({$text : {$search : "abc"}})
      { "_id" : 1, "arr" : [ "abc xyz", "def" ] }
      { "_id" : 2, "arr" : [ "jadskf", "ljh abc" ] }
      

      Ideally I'd like to only obtain the first element of the arr in the first document: abc xyz and only the second element of the arr in the second document: ljh abc, and also the _id of the matched documents.

      Note that what I want is not a simple projection of the arr element, but of the elements of the arr where the match occurred.

            Assignee:
            backlog-query-integration [DO NOT USE] Backlog - Query Integration
            Reporter:
            cmmp Cássio Martini Martins Pereira
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: