Skip to Main Content

MongoByte MongoDB Logo

Welcome to the new MongoDB Feedback Portal!

{Improvement: "Your idea"}
We’ve upgraded our system to better capture and act on your feedback.
Your feedback is meaningful and helps us build better products.

Status Submitted
Categories Atlas Search
Created by Guest
Created on Aug 4, 2023

Sort by a specific array index

When creating indexes and sorting with "normal" queries, it is possible to index/sort on a specific array index (e.g. `foo.0.bar`). I do this because the search results grid in our UI only has room to show the first `foo.bar` result, so it doesn't make sense visually to sort by additional objects which the user can't see. Since the new Atlas Search Sort syntax looks the same, I was hoping to do that with it as well, but it doesn't seem possible. Example: ``` [ { "xyzzy": "xyzzy", "foo": [ { "bar": "A" } ] }, { "xyzzy": "xyzzy", "foo": [ { "bar": "B" }, { "bar": "D" } ] }, { "xyzzy": "xyzzy", "foo": [ { "bar": "C" } ] } ] ``` ``` { index: "myindex", returnStoredSource: true, phrase: { path: "xyzzy", query: "xyzzy" }, sort: { "foo.0.bar": -1 } } ``` See: https://support.mongodb.com/case/01169701
  • Guest
    Aug 14, 2023
    While this feature would be valuable for me, I've had a better idea that would solve it and all kinds of other scenarios as well: https://feedback.mongodb.com/forums/924868-atlas-search/suggestions/47081989-allow-aggregate-pipeline-on-input-documents-before