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

Data type coercion when document field type doesn't match index field type

When a document field type doesn't match the index field type, it seems to be indexed as "blank" and won't match anything. Many data types are readily convertible between type representations. It would be great if Atlas Search could do that for us and would open up richer functionality by allowing us to use operators/analyzers/etc. on types that don't normally support them. My particular use case is to allow searching & sorting on numbers stored as strings. When creating indexes and sorting with "normal" queries, it is possible to sort numbers stored as strings by their numerical ordering rather than alphabetical by using `{ collation: { locale: "en_US", numericOrdering: true } }` on the index definition and applying `query.collation(Collation.of(Locale.US).numericOrdering(true))` to the query itself. I was hoping to do this with Atlas Search Sort as well, but it isn't possible. Examples: string `"1000.00"` = number `1000.00` boolean `true` = number `1` boolean `true` = string `"true"` etc. See: https://support.mongodb.com/case/01169737
  • 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
  • Guest
    Aug 4, 2023
    Alternatively, I would also be happy if the specific case of using numeric ordering on strings were added to the new sort feature, like you can with normal queries. But generalized type coercion would be more broadly useful.