Comments (4)
You have to add your properties as field along your item if you want to filter on them using a SCAN/WITHIN/INTERSECT query. But even then I'm not sure if filtering for values in an array is possible at all with expr.
If you application allows, you're better of adding a isAdmin
(true/false) field, and if performance is critical I suggest to an explicit field like so
# with field numerical values which is faster than filter expressions)
SET collection item1 FIELD isAdmin 1 OBJECT '{"type":"Feature","geometry":{"type":"Point","coordinates":[-112,33]},"properties":{"speed":55,"age":23,"name":"Carol","role":["admin","user","guest"]}}'
SET collection item2 FIELD isAdmin 2 OBJECT '{"type":"Feature","geometry":{"type":"Point","coordinates":[-112,33]},"properties":{"speed":55,"age":23,"name":"Carol","role":["user","guest"]}}'
SCAN collection WHERE isAdmin 1 1
>> returns item1 only
SCAN collection WHERE isAdmin 1 2
>> returns item1 and item2
SCAN collection WHERE isAdmin 2 2
>> returns item2 only
alternatively you can use filter expression in your where query like so:
# with filter expressions
SET collection item1 FIELD isAdmin true OBJECT '{"type":"Feature","geometry":{"type":"Point","coordinates":[-112,33]},"properties":{"speed":55,"age":23,"name":"Carol","role":["admin","user","guest"]}}'
SET collection item2 FIELD isAdmin false OBJECT '{"type":"Feature","geometry":{"type":"Point","coordinates":[-112,33]},"properties":{"speed":55,"age":23,"name":"Carol","role":["user","guest"]}}'
SCAN collection WHERE 'isAdmin === true'
>> returns item1 only
SCAN collection
>> returns item1 and item2
SCAN collection WHERE 'isAdmin === false'
>> returns item2 only
from tile38.
You could experiment with WHEREEVAL
that you can pass a LUA script to filter. I'm not familiar with how-to and it is not documented in detail how to achieve that, so you're most likely on your own. There might be somebody on the Tile38 slack that can help you maybe.
from tile38.
Many thanks.
from tile38.
Thanks for your response. But in my case, I have a array with many options. Example:
{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [-112, 33] },
"properties": {
"speed": 55,
"age": 23,
"name": "Carol",
"hobbies": ["music", "game", "sport", "dance", "racing", ...... ]
}
}
So I can not set isMusic
for each element in that array. Do you have any other solution ?
from tile38.
Related Issues (20)
- Tile38 does not support EXISTS command. HOT 2
- FSET does not have a FGET counterpoint HOT 2
- 使用tile
- 使用tile38如何判断点是否在库中存储的区域对象中
- How can I tell if a point is in a region with tile38 HOT 2
- How to execute INTERSECTS command through StatefulRedisConnection in Spring
- GOPATH / GOROOT HOT 2
- tile38 How to calculate the distance between two points HOT 1
- tile38 How to calculate the distance between two points HOT 1
- Invalid JSON created when setting a field to a string value like '000296'. HOT 4
- WebSocket interface doesn't reply to requests after connection upgrade HOT 7
- tile38 use Geofencing watches
- Bug: Tile38 followers can get out of sync with leaders HOT 2
- FSET transforms field names to lowercase HOT 7
- The arm64 environment is not running properly HOT 3
- Issue with WITHIN Query in Tile38 Geofencing HOT 10
- Tile38 unable to write and getting crash HOT 4
- ROLE command with JSON output has extra quote HOT 1
- Tile38 is not publishing its db stats to redis sentinel which causes sentinel to pick wrong master HOT 2
- TILE38 cpu spikes with lots of geofences and kafka hooks
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tile38.