1

Do we have any alternative solution to search with the Decimal128 field in Mongo DB Atlas search?

I tried to create an Atlas index with Number but it seems they support only int32, int64 and double. Decimal 128 doesn't work with this index.

{
    "mappings": {
        "dynamic": false,
        "fields": {
            "totalAmountTaxIncluded": {
                "fields": {
                    "value": {
                        "type": "number"
                    }
                },
                "type": "document"
            }
        }
    }
}

Here is my Query:

{
    "$search": {
        "index": "invoice_search",
        "compound": {
            "must": [{
                "range": {
                    "path": "totalAmountTaxIncluded.value",
                    "gte": 300,
                    "lte": 300
                }
            }]
        }
    }
}

In the above query, I tried to fetch the invoice with totalAmountTaxIncluded.value of 300.

Bathri Nathan
  • 1,101
  • 2
  • 13
  • 17
  • How are you querying? Do you have any examples of queries that don't work? – Joe Oct 08 '21 at 22:49
  • @Joe, sorry for the late reply, I have shared my index and query in the post. thanks in advance – Bathri Nathan Oct 13 '21 at 13:23
  • In the index definition, try adding a `fields` object to contain `totalAmountTaxIncluded`. – Joe Oct 13 '21 at 15:17
  • I have already created a field called totalAmountTaxIncluded but it cannot perform search operations on decimal128. but when I change the data type of "totalAmountTaxIncluded.value" to double or int it works. for my case, I am looking for Decimal128 – Bathri Nathan Oct 14 '21 at 14:02
  • The docs at https://docs.atlas.mongodb.com/reference/atlas-search/index-definitions/ don't list an atlas search type that corresponds to decimal128. You might need to check with their support if that is available or not. – Joe Oct 14 '21 at 16:28
  • @Joe yes exactly. I could not find it in the documentation that's why I tried to create a post to find some information about this. – Bathri Nathan Oct 15 '21 at 07:12

0 Answers0