Need help with geo spatial ingest and query

467 views
Skip to first unread message

nan...@netskope.com

unread,
Sep 28, 2016, 1:27:36 PM9/28/16
to Druid User
Hi,

I'm having trouble getting filtering by spatial dimensions to work. I'm testing with the latest imply container (1.3.0)

I created a sample data point for testing, that looks like this - 

{

   "bytes" : 2208,

   "longitude" : -122.0,

   "app" : "gmail",

   "timestamp" : 1463170946,

   "latitude" : 37.4,

   "user" : "abc@domain"

}


My ingest spec has this dimensionsSpec attribute - 

      "parser" : {

        "type" : "string",

        "parseSpec" : {

          "format" : "json",

          "timestampSpec" : {

            "column" : "timestamp",

            "format" : "posix"

          },

          "dimensionsSpec" : {

            "dimensions": ["app","user"],

            "dimensionExclusions" : [],

            "spatialDimensions" : [

                { "dimName": "location", "dims":["latitude", "longitude"]}

            ]

          }

        }

      },

My understanding is that this makes lat and long available for filtering via the alias 'location'. So I was expecting this query to work - 

    "filter": {

        "type": "spatial",

        "dimension": "location",

        "bound": {

            "maxCoords": [

                0.0,

                90.0

            ],

            "type": "rectangular",

            "minCoords": [

                -180.0,

                0.0

            ]

        }

    },


but it returns an empty result set. I should mention this filter is part of a 'groupBy' query, where I group by app and user. When I remove the filter, I see the expected results, so at least that I know the data was ingested. 


Another question - does Druid support ingestion of geo data where the coordinates are contained in an array like so - {'location': [-122.0, 37.4]} instead of separate latitude and longitude attributes ? If so, how do I specify this in the ingest spec? Can it say - { 'spatialDimensions': [ {'dimName': 'location'} ] } ?


I've looked at other posts related to spatial dimensions, but can't find one that matches the exact same issue. Any help would be greatly appreciated.


thanks

Nandan

Gian Merlino

unread,
Sep 29, 2016, 2:50:51 PM9/29/16
to druid...@googlegroups.com
Hey Nandan,

Your input coordinate is [37.4, -122.0] but your filter on x is [-180, 0] and your filter on y is [0, 90]. So that won't match your coordinate. Just for a sanity check, try a radius bound centered on your point [37.4, -122.0] with a small radius and see if that matches.

Gian

--
You received this message because you are subscribed to the Google Groups "Druid User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to druid-user+unsubscribe@googlegroups.com.
To post to this group, send email to druid...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/druid-user/9779f8ae-9649-4a42-aca5-c13954fca801%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

nan...@netskope.com

unread,
Sep 29, 2016, 4:53:30 PM9/29/16
to Druid User
Hi Gian,

Is this the format for the radius query ? 

    "filter": {

        "type": "spatial",

        "dimension": "location",

        "bound": {

            "coords": [

                37.4,

                -122.0

            ],

            "type": "radius",

            "radius": 1000.0

        }

    }


If so, this doesn't work either - it returns an empty result set.  I don't see any errors in var/sv/broker.log.

Also, I had previously assumed the 'x' coordinate in the query was longitude, not latitude. For the ingest spec it's clearly spelt out in http://druid.io/docs/latest/development/geo.html that the first of the 2 values is latitude. Either way, I switched the order of the lat and long values in the original rectangle query and that didn't work either.

thanks
Nandan

Gian

To unsubscribe from this group and stop receiving emails from it, send an email to druid-user+...@googlegroups.com.

nan...@netskope.com

unread,
Sep 30, 2016, 3:50:43 PM9/30/16
to Druid User
Any suggestions Gian ? I can upload the entire ingest spec and query if that would help.

thanks

Fangjin Yang

unread,
Oct 7, 2016, 6:01:53 PM10/7/16
to Druid User
That filter looks correct. What do you mean nothing is returned? Do you get an empty result or a count of 0?
If you a timeseries query with just a count aggregator, do you get a correct count back?
Reply all
Reply to author
Forward
0 new messages