tidwall / tile38

Real-time Geospatial and Geofencing
https://tile38.com
MIT License
8.97k stars 561 forks source link

Support searching from Muti JSON documents ? #142

Open icewukong opened 7 years ago

icewukong commented 7 years ago

For example:

   SET roads road1 OBJECT {"type": "LineString",coordinates": [[102.0, 0.0], [103.0, 1.0], [104.0,0.0],[105.0, 1.0]]},"properties": {"prop0": "value0","prop1": 0.0}}
   SET roads road2 OBJECT {"type": "LineString",coordinates": [[102.0, 0.0], [103.0, 1.0], [104.0,0.0],[105.0, 1.0]]},"properties": {"prop0": "value1","prop1": 2.0}}

I want to return the object that it's "prop0" equal "value1",with a command: JSEARCH key MATCH path e.g. JSEARCH roads MATCH properties.#[prop0=="value1"]#

tidwall commented 7 years ago

It's possible, but it would be slow. An O(n) operation. Would that be OK?

icewukong commented 7 years ago

How about to create a index,like buntdb? Despite this will expose the concept of the index. Maybe it need to provide a command to create a custom index. Anyway,for me, it's better to be slow than not. Thank you for reply!

icewukong commented 7 years ago

BTW, Is the SEARCH operation on type STRING an O(n) operation?

tidwall commented 7 years ago

No, the STRING type goes into a Btree. It's in binary order. O(log n) We may be able to add a command for creating indexes for collections. Similar to SETINDEX in SummitDB.

icewukong commented 7 years ago

That would be best!

tidwall commented 7 years ago

All right. I'll investigate further. Thanks for you input.

icewukong commented 6 years ago

Will the ability that searching from Muti JSON documents be available in version 2.x ? Same as issue #200 would be OK.

tidwall commented 6 years ago

I hope so. I'm experimenting with new SETINDEX & DELINDEX commands, and an updated SEARCH command that will allow for indexed queries on the STRING type.

icewukong commented 6 years ago

Looking forward to your project 2.0 :+1:

kirantpatil commented 3 years ago

Hi,

May I know the commands to search with json field using NEARBY and WHERE ?

For example:

127.0.0.1:9851> jset test 1 outstation dharwad {"ok":true,"elapsed":"49.379µs"}

127.0.0.1:9851> get test 1 {"ok":true,"object":{"type":"Point","coordinates":[-84.4767280575,45.6304059969,100],"outstation":"dharwad"},"elapsed":"34.099µs"}

127.0.0.1:9851> nearby test where outstation dharwad 6000 (error) invalid argument 'dharwad'

kirantpatil commented 3 years ago

I hope so. I'm experimenting with new SETINDEX & DELINDEX commands, and an updated SEARCH command that will allow for indexed queries on the STRING type.

@tidwall: May I know any updates on this feature ?

tidwall commented 3 years ago

Hi @kirantpatil. Sorry but this feature is on hold and I don’t have any plans at the moment to implement right now.