Query document that has a decimal in a string key


#1

I have a document where I want the keys to be a numeric string with a decimal in them as follows:

INSERT INTO default (KEY,VALUE) VALUES (“discountIds”, {“discounts”: {“2.65”: {“code”: “Discount $2.65”,“amount”: 2.65}}});

I then want to query for the existence of a given key, for example, “2.65”. I tried a number of different things, including:

SELECT discounts.‘2.65’
FROM default USE KEYS ‘discountIDs’

Is it possible to have a key like this and be able to query for it?


#2

Use back-ticks As described here https://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/identifiers.html

SELECT discounts.`2.65`
FROM default USE KEYS ["discountIds"];

#3

Thanks! Forgot about the back-ticks