Searching Data Within a Value Range
The following topics explain how to search for records with values within a specific range for a selected attribute, and how to persist data in a manner that allows such search operations to be carried out.
Persisting attributes
Data can be searched by value range only for attributes with numeric values. Therefore, the data type of the attribute by which the search is carried out should be INTEGER
or FLOAT
. The attribute should also be persisted as an index column as shown below.
Generating data
There are no specific guidelines to follow at the time of entering data in order to allow this search operation.
Searching for Data
e.g., The following cURL command can be used to search for events of which the price is between 5.00
and 7.00
.
curl -X POST -H "Content-Type: application/json" -H "Authorization: Basic YWRtaW46YWRtaW4=" -v https://localhost:9443/analytics/search -d '{"tableName":"BookStore", "query":"correlation_Price:[5.00 TO 7.00]", "start":0, "count":100}' -k
It returns a response similar to the following.
[{"id":"1727106f-5cd9-3249-8328-b952a0bcef27","tableName":"BOOKSTORE","timestamp":1485763627000,"values":{"meta_Transaction_ID":"BSP0000007","correlation_Title":"The Adventures of Sherlock Holmes","correlation_Date":"2017,01,30","Value":90.0,"correlation_Author":"Arthur,Conan,Doyle","correlation_Price":6.0,"correlation_Discount":0.25,"correlation_Quantity":15,"_version":"1.0.0"}},{"id":"53dba6d7-2ed2-3710-9c98-2a20f0a71766","tableName":"BOOKSTORE","timestamp":1506931625000,"values":{"meta_Transaction_ID":"BSP0000011","correlation_Title":"Mary Called Magdalene","correlation_Date":"2016,10,02","Value":70.0,"correlation_Author":"Margaret,George","correlation_Price":7.0,"correlation_Discount":0.5,"correlation_Quantity":10,"_version":"1.0.0"}},{"id":"af3d4a10-0c7b-34b1-b436-793368d2877d","tableName":"BOOKSTORE","timestamp":1475741225000,"values":{"meta_Transaction_ID":"BSP0000002","correlation_Title":"Childhood's End","correlation_Date":"2016,10,06","Value":66.0,"correlation_Author":"Arthur,C,Clarke","correlation_Price":5.5,"correlation_Discount":0.0,"correlation_Quantity":12,"_version":"1.0.0"}},{"id":"7959f493-34f0-3755-84ea-92a96101c9a4","tableName":"BOOKSTORE","timestamp":1485763625000,"values":{"meta_Transaction_ID":"BSP0000013","correlation_Title":"Elizabeth I","correlation_Date":"2017,01,30","Value":70.0,"correlation_Author":"Margaret,George","correlation_Price":7.0,"correlation_Discount":0.5,"correlation_Quantity":10,"_version":"1.0.0"}},{"id":"3c251430-c915-3c8c-9c03-6dc3364865aa","tableName":"BOOKSTORE","timestamp":1483344425000,"values":{"meta_Transaction_ID":"BSP0000015","correlation_Title":"1984","correlation_Date":"2017,01,02","Value":139.8,"correlation_Author":"George,Orwell","correlation_Price":6.99,"correlation_Discount":0.0,"correlation_Quantity":20,"_version":"1.0.0"}},{"id":"5254de6d-6df0-3d82-b3a5-d1aba76adb18","tableName":"BOOKSTORE","timestamp":1475741225000,"values":{"meta_Transaction_ID":"BSP0000002","correlation_Title":"Childhood's End","correlation_Date":"2016,10,06","Value":66.0,"correlation_Author":"Arthur,C,Clarke","correlation_Price":5.5,"correlation_Discount":0.0,"meta_Purchase_Batch_ID":"P000003","correlation_Quantity":12,"_version":"1.0.0"}},{"id":"00837303-2c04-3075-aca3-f5e702cc4574","tableName":"BOOKSTORE","timestamp":1478160426000,"values":{"meta_Transaction_ID":"BSP0000008","correlation_Title":"A Study in Scarlet","correlation_Date":"2016,11,03","Value":75.0,"correlation_Author":"Arthur,Conan,Doyle","correlation_Price":5.0,"correlation_Discount":0.25,"meta_Purchase_Batch_ID":"P000008","correlation_Quantity":15,"_version":"1.0.0"}},{"id":"09ce7320-4795-3461-ad8e-69e6dfc45f73","tableName":"BOOKSTORE","timestamp":1472717226000,"values":{"meta_Transaction_ID":"BSP0000010","correlation_Title":"Gone With the Wind","correlation_Date":"2016,09,01","Value":136.6,"correlation_Author":"Margaret,Mitchell","correlation_Price":6.83,"correlation_Discount":0.0,"correlation_Quantity":20,"_version":"1.0.0"}},{"id":"f9011238-7699-3133-af50-d5ae37ef2f2c","tableName":"BOOKSTORE","timestamp":1503994025000,"values":{"meta_Transaction_ID":"BSP0000012","correlation_Title":"Memoirs of Cleopatra","correlation_Date":"2016,08,29","Value":70.0,"correlation_Author":"Margaret,George","correlation_Price":7.0,"correlation_Discount":0.5,"meta_Purchase_Batch_ID":"P000014","correlation_Quantity":10,"_version":"1.0.0"}},{"id":"489f17c8-884f-3f0f-80a9-29cf06e660d7","tableName":"BOOKSTORE","timestamp":1483603625000,"values":{"meta_Transaction_ID":"BSP0000004","correlation_Title":"Emma","correlation_Date":"2017,01,05","Value":134.6,"correlation_Author":"Jane,Austen","correlation_Price":6.73,"correlation_Discount":0.0,"correlation_Quantity":20,"_version":"1.0.0"}},{"id":"4b68cbf0-51ea-3388-844b-bfa7847c9ffa","tableName":"BOOKSTORE","timestamp":1477901225000,"values":{"meta_Transaction_ID":"BSP0000006","correlation_Title":"The Origin of Species","correlation_Date":"2016,10,31","Value":125.0,"correlation_Author":"Charles,Darwin","correlation_Price":6.25,"correlation_Discount":0.0,"correlation_Quantity":20,"_version":"1.0.0"}},{"id":"40f81b74-ef7d-3de6-a776-d74c2c1aa59d","tableName":"BOOKSTORE","timestamp":1478160426000,"values":{"meta_Transaction_ID":"BSP0000008","correlation_Title":"A Study in Scarlet","correlation_Date":"2016,11,03","Value":75.0,"correlation_Author":"Arthur,Conan,Doyle","correlation_Price":5.0,"correlation_Discount":0.25,"correlation_Quantity":15,"_version":"1.0.0"}},{"id":"bc2f030e-6822-3dca-a94d-49aca0713bb2","tableName":"BOOKSTORE","timestamp":1472717225000,"values":{"meta_Transaction_ID":"BSP0000003","correlation_Title":"Oliver Twist","correlation_Date":"2016,09,01","Value":139.2,"correlation_Author":"Charles,Dickens","correlation_Price":6.96,"correlation_Discount":0.0,"meta_Purchase_Batch_ID":"P000001","correlation_Quantity":20,"_version":"1.0.0"}},{"id":"bd91a858-fd84-3cf0-861e-7c44c8a1e542","tableName":"BOOKSTORE","timestamp":1483603625000,"values":{"meta_Transaction_ID":"BSP0000004","correlation_Title":"Emma","correlation_Date":"2017,01,05","Value":134.6,"correlation_Author":"Jane,Austen","correlation_Price":6.73,"correlation_Discount":0.0,"meta_Purchase_Batch_ID":"P000010","correlation_Quantity":20,"_version":"1.0.0"}},{"id":"2195bd0c-daa8-3d3f-952f-bc75f3cc39d9","tableName":"BOOKSTORE","timestamp":1485763625000,"values":{"meta_Transaction_ID":"BSP0000013","correlation_Title":"Elizabeth I","correlation_Date":"2017,01,30","Value":70.0,"correlation_Author":"Margaret,George","correlation_Price":7.0,"correlation_Discount":0.5,"meta_Purchase_Batch_ID":"P000011","correlation_Quantity":10,"_version":"1.0.0"}},{"id":"6063467c-d29c-3c26-ab5f-e4e54a7fc84a","tableName":"BOOKSTORE","timestamp":1472717225000,"values":{"meta_Transaction_ID":"BSP0000003","correlation_Title":"Oliver Twist","correlation_Date":"2016,09,01","Value":139.2,"correlation_Author":"Charles,Dickens","correlation_Price":6.96,"correlation_Discount":0.0,"correlation_Quantity":20,"_version":"1.0.0"}},{"id":"33cc704f-962a-3ccc-b037-2d957e413f94","tableName":"BOOKSTORE","timestamp":1477901225000,"values":{"meta_Transaction_ID":"BSP0000006","correlation_Title":"The Origin of Species","correlation_Date":"2016,10,31","Value":125.0,"correlation_Author":"Charles,Darwin","correlation_Price":6.25,"correlation_Discount":0.0,"meta_Purchase_Batch_ID":"P000005","correlation_Quantity":20,"_version":"1.0.0"}},{"id":"cea98647-3155-3742-977e-1992c9d1964b","tableName":"BOOKSTORE","timestamp":1506931625000,"values":{"meta_Transaction_ID":"BSP0000011","correlation_Title":"Mary Called Magdalene","correlation_Date":"2016,10,02","Value":70.0,"correlation_Author":"Margaret,George","correlation_Price":7.0,"correlation_Discount":0.5,"meta_Purchase_Batch_ID":"P000015","correlation_Quantity":10,"_version":"1.0.0"}},{"id":"1ffce922-5ed2-3dec-bc83-f5bef9aa32cd","tableName":"BOOKSTORE","timestamp":1483344425000,"values":{"meta_Transaction_ID":"BSP0000015","correlation_Title":"1984","correlation_Date":"2017,01,02","Value":139.8,"correlation_Author":"George,Orwell","correlation_Price":6.99,"correlation_Discount":0.0,"meta_Purchase_Batch_ID":"P000009","correlation_Quantity":20,"_version":"1.0.0"}},{"id":"5247a7f0-bd41-3270-b4b7-51a7edc9ddf3","tableName":"BOOKSTORE","timestamp":1478150269000,"values":{"meta_Transaction_ID":"BP0000017","correlation_Title":"Kim","correlation_Date":"2016.11,03","Value":66.0,"correlation_Author":"Rudyard,Kipling","correlation_Price":5.5,"correlation_Discount":0.25,"meta_Purchase_Batch_ID":"P000017","correlation_Quantity":12,"_version":"1.0.0"}},{"id":"c22b9285-3669-38c3-9e86-2cd2086c5f02","tableName":"BOOKSTORE","timestamp":1478160425000,"values":{"meta_Transaction_ID":"BSP0000001","correlation_Title":"The Invisible Man: A Grotesque Romance","correlation_Date":"2016,11,03","Value":79.92,"correlation_Author":"Arthur,C,Clarke","correlation_Price":6.66,"correlation_Discount":0.0,"correlation_Quantity":12,"_version":"1.0.0"}},{"id":"281e4ce2-0051-3c1f-8924-0533511a1b0c","tableName":"BOOKSTORE","timestamp":1503994025000,"values":{"meta_Transaction_ID":"BSP0000012","correlation_Title":"Memoirs of Cleopatra","correlation_Date":"2016,08,29","Value":70.0,"correlation_Author":"Ma* Connection #0 to host localhost left intact
rgaret,George","correlation_Price":7.0,"correlation_Discount":0.5,"correlation_Quantity":10,"_version":"1.0.0"}},{"id":"9f614e49-6229-3457-9f0a-6a7edcfb76c3","tableName":"BOOKSTORE","timestamp":1478160425000,"values":{"meta_Transaction_ID":"BSP0000001","correlation_Title":"The Invisible Man: A Grotesque Romance","correlation_Date":"2016,11,03","Value":79.92,"correlation_Author":"Arthur,C,Clarke","correlation_Price":6.66,"correlation_Discount":0.0,"meta_Purchase_Batch_ID":"P000007","correlation_Quantity":12,"_version":"1.0.0"}},{"id":"c9b6d1f8-561d-3258-b3eb-8ddd63f135c7","tableName":"BOOKSTORE","timestamp":1485763627000,"values":{"meta_Transaction_ID":"BSP0000007","correlation_Title":"The Adventures of Sherlock Holmes","correlation_Date":"2017,01,30","Value":90.0,"correlation_Author":"Arthur,Conan,Doyle","correlation_Price":6.0,"correlation_Discount":0.25,"meta_Purchase_Batch_ID":"P000012","correlation_Quantity":15,"_version":"1.0.0"}},{"id":"7dde0cf5-bd42-3df3-add7-6a91b3cb1eb4","tableName":"BOOKSTORE","timestamp":1472717226000,"values":{"meta_Transaction_ID":"BSP0000010","correlation_Title":"Gone With the Wind","correlation_Date":"2016,09,01","Value":136.6,"correlation_Author":"Margaret,Mitchell","correlation_Price":6.83,"correlation_Discount":0.0,"meta_Purchase_Batch_ID":"P000002","correlation_Quantity":20,"_version":"1.0.0"}}]