I try to do a SQL query on Hazelcast map.
ata in the map is in Json format.
How can I do a query with json filter ? I need to get all data with hasEvents == true
I tried to do this filter :
select JSON_QUERY(this, '$.data.field1.hasEvents?==true') from products
but it doesn’t work
I expect to get all the entries in the map where data.field1.hasEvents = true
2
Answers
Assume that you have this table structure
Your SQL should be something like
I am using hz 5.4.0-SNAPSHOT in this example. Link to the complete example is here
https://github.com/OrcunColak/hzjetclient/blob/c8b526d0160ab3a2eb576716e314a262898feef4/src/main/java/com/colak/jet/sql/json/json_query/JsonQueryIMapTest.java
This is the test skeleton
This method creates an embedded hz server
Let’s populate the map
This one creates a mapping. I have copied from your example
Now select from the mapping that uses underlying IMap
I can see from the output that it selects the entry having key = 2