I have followed the guidelines on how to index json fields from Microsoft here.
Here is an example:
ALTER TABLE Sales.SalesOrderHeader
ADD vCustomerName AS JSON_VALUE(Info,'$.Customer.Name')
CREATE INDEX idx_soh_json_CustomerName
ON Sales.SalesOrderHeader(vCustomerName)
I have 2 computed columns though (should not matter I think), and then I get this warning:
Warning! The maximum key length for a nonclustered index is 1700 bytes. The index 'IX_vType_vTime' has maximum length of 16000 bytes. For some combination of large values, the insert/update operation will fail.
This seems legitimate since JSON_VALUE returns nvarchar(4000), so maximum is 16000 bytes. Is there any need to do something with it?
E.g. conversion to nvarchar(50) during computation?