Commit Graph

25 Commits

Author SHA1 Message Date
tidwall bdc80a7f70 Added WHERE expressions
It's now possible to do:

   SCAN fleet WHERE "properties.speed < 25 || properties.speed > 50"

Uses javascript-like syntax using the https://github.com/tidwall/expr package.

Automatically reference fields and GeoJSON properties:

   SET fleet truck1 FIELD speed 65 POINT -112 33

Can be queried:

   SCAN fleet WHERE "speed > 50"
   SCAN fleet WHERE "id == 'truck1'"
   SCAN fleet WHERE "speed > 50 && id == 'truck1'"
2022-10-20 17:01:12 -07:00
tidwall cf7f49fd9b Add field path queries for json and comparison operators
It's now possible to query a JSON field using a GJSON path.

   SET fleet truck1 FIELD props '{"speed":58,"name":"Andy"}' POINT 33 -112

You can then use the GJSON type path to return the objects that match the WHERE.

   SCAN fleet WHERE props.speed 50 inf
   SCAN fleet WHERE props.name Andy Andy

Included in this commit is support for '==', '<', '>', '<=', '>=', and '!='.
The previous queries could be written like:

    SCAN fleet WHERE props.speed > 50
    SCAN fleet WHERE props.name == Andy
2022-10-20 11:17:01 -07:00
tidwall d5c148ca41 Field overhaul 2022-09-19 17:47:38 -07:00
tidwall f24c251ee6 Allow for multiple MATCH patterns
Each MATCH is inclusive OR, thus

    WITHIN fleet MATCH train* truck* BOUNDS 33 -112 34 -113

will find all trains and trucks that within the provides bounds.
2022-09-01 19:43:30 -07:00
tidwall 241117c7ba Added BUFFER option for Within and Intersects
This commit allows for buffering any GeoJSON object.

For example:

    INTERSECTS fleet BUFFER 1000 OBJECT {...LineString...}

This will buffer add a 1 kilometer buffer to a linesting and
search the 'fleet' collection for all objects that
intersect the buffered linestring.

This commit also allows for performing INTERSECTS with a POINT
type. Thus allowing for a polygon-over-point operation, which is
an inverted point-in-polygon.
2021-12-09 18:14:50 -07:00
Benjamin Ramser bc62edb692 feat: add sector 2021-09-05 11:48:34 +02:00
tidwall 0d83b1ca53 Merge branch 'rshura-optimize-field-match' 2021-07-10 17:59:22 -07:00
Josh 1467cba769
Merge pull request #552 from rshura/clip-by
Add CLIPBY subcommand to INTERSECTS/WITHIN
2021-07-10 09:24:57 -07:00
tidwall 6b08f7fa9e Code cleanup
- Removed unused functions and variables
- Wrapped client formatted errors
- Updated deprecated packages
- Changed suggested code patterns
2021-03-31 08:13:44 -07:00
tidwall 9093926135 Limit geohash precision to 12 2020-08-12 10:58:49 -07:00
Alex Roitman 25579a052c Fix a bug in WHEREIN -- 0 values would always match, incorrectly. 2020-04-12 16:06:10 -07:00
Alex Roitman 34cb2affdc Add clipby subcommand to INTERSECTS/WITHIN 2020-04-03 16:49:06 -07:00
Alex Roitman d5132a9eae Map field names to array indices in scanwriter, once per query. 2020-03-25 15:15:06 -07:00
Alex Roitman 9e7766b346 Array of values instead of map for whereins. 2020-03-25 15:14:51 -07:00
tidwall c084aeedc2 Code cleanup
This commit cleans up various Go code in the internal directory.
- Ensures comments on exported functions
- Changes all *Server receiver in all files to be "s", instead
  of mixed "c", "s", "server", etc.
- Silenced Go warnings for if/else with returns.
- Cleaned up import ordering.
2019-10-30 10:17:59 -07:00
Alex Roitman dd09ffbe13 Fix parser for multiple negations. 2019-06-14 10:02:26 -07:00
Alex Roitman 7c541949b1 Unnecessary code. 2019-06-13 14:12:42 -07:00
Alex Roitman 2d83e18934 Add expression errors test. Make parser stricter. 2019-06-13 13:10:47 -07:00
Alex Roitman 0c3a5d02ca Fixes 2019-06-13 12:04:04 -07:00
Alex Roitman 496ace25d3 Refactoring/cleanup/fixes. 2019-06-11 17:13:33 -07:00
Alex Roitman d0ca579f5c Add area expressions.
Add parser.
Hook up to test command.
Add tests for expressions in test command.
2019-06-10 14:47:42 -07:00
Alex Roitman cbf10b7472 Rework timeouts to allow prepending any command with the TIMEOUT seconds 2019-04-25 14:15:53 -07:00
Alex Roitman e514a0287f Add timeout subcommand to scan/search commands.
Use per-query timeout for those commands, if it was given.
2019-04-24 12:02:39 -07:00
Alex Roitman 01a7dda2a1 Add RENAME and RENAMENX commands. 2018-12-27 17:15:53 -08:00
tidwall 555e47036c Replaced net package with evio
- Added threads startup flag
- Replaced net package with evio
- Refactored controller into server
2018-10-28 15:51:47 -07:00