Giter Club home page Giter Club logo

Comments (4)

iwpnd avatar iwpnd commented on September 23, 2024 1

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.

iwpnd avatar iwpnd commented on September 23, 2024 1

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.

DucPhan2997 avatar DucPhan2997 commented on September 23, 2024 1

Many thanks.

from tile38.

DucPhan2997 avatar DucPhan2997 commented on September 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.