koopjs / koop-provider-elasticsearch

A provider for koop that can connect to one or more elastic search instances and turn indices/aliases into individual feature services.
Apache License 2.0
13 stars 4 forks source link

Time enabled layers not working in ES #11

Closed keithfraley closed 6 years ago

keithfraley commented 6 years ago

I have added the following to the metadata section of the provider.

            "timeInfo": {
                "startTimeField": "eventtime",
                "endTimeField": "eventtime",
                "trackIdField": null,
                "hasLiveData": true,
                "timeExtent": [new Date(Date.now() - 86400 * 1000).getTime(), Date.now()],
                "timeInterval": 1,
                "timeIntervalUnits": "esriTimeUnitsDays"
            }

I can get the time slider to popup, but the features that come back are not time aware, the query still brings back everything.

https://github.com/koopjs/koop-provider-elasticsearch/blob/master/provider/models/esmodel.js#L22-L24

dhatcher commented 6 years ago

I think you'd still need to set there where clause to a time extent to get that to work. You could add it to the where clause in code or else set it in the web application.

rgwozdz commented 6 years ago

Also, perhaps trackIdField should not be null. http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.TemporalRenderer~TrackIdField.html

keithfraley commented 6 years ago

Rich, the koop demo you showed worked with the timeslider in agol so I am assuming it is an issue with the es provider?

I noticed that the query strings are slightly different

When I use a filter on a date field the qs looks like this (THIS WORKS)

where=MYDATEFIELD%20BETWEEN%20timestamp%20%272018-04-24%2005%3A00%3A00%27%20AND%20timestamp%20%272018-04-25%2004%3A59%3A59%27

When I use a timeslider date field the qs looks like this (THIS DOESNT WORK)

&time=1524599460000%2C1524772260000

Notice no reference to the field?

This is my config, same as the example you sent.

timeInfo: { startTimeField: "MYDATEFIELD", endTimeField: null, trackIdField: null, timeExtent: [new Date(Date.now() - 86400 * 1000).getTime(), Date.now()], timeReference: { timeZone: "Pacific Standard Time", respectsDaylightSaving: true }, timeInterval: 2, timeIntervalUnits: "esriTimeUnitsDays", exportOptions: { useTime: true, timeDataCumulative: false, timeOffset: null, timeOffsetUnits: null }, hasLiveData: true },

rgwozdz commented 6 years ago

Hmm, I notice your timeExtent is set from this time yesterday to "now". Is it possible that your data don't have timestamps in that range? Also the filter &time=1524599460000%2C1524772260000 converts to Tuesday, April 24, 2018 7:51:00 PM Thursday, April 26, 2018 7:51:00 PM. Is your data in that range?

keithfraley commented 6 years ago

It brings back all data, no filter at all.

On Wed, Apr 25, 2018, 9:30 PM Rich Gwozdz notifications@github.com wrote:

Hmm, I notice your timeExtent is set from this time yesterday to "now". Is it possible that your data don't have timestamps in that range? Also the filter &time=1524599460000%2C1524772260000 converts to Tuesday, April 24, 2018 7:51:00 PM Thursday, April 26, 2018 7:51:00 PM. Is your data in that range?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/koopjs/koop-provider-elasticsearch/issues/11#issuecomment-384493251, or mute the thread https://github.com/notifications/unsubscribe-auth/ADyxVAkWPe_wMhDCPS2wPIVxB6-rKyoOks5tsTEvgaJpZM4Tjb6l .

rgwozdz commented 6 years ago

hmm, ok. I think I see what your are getting at. Maybe the timeslider is working fine, but the queries it generates aren't working in winnow. I have been assuming the time slider is not re-querying Koop on every slider event and it was doing the filtering on the fly, itself. I don't know that for sure though. We should confirm.

keithfraley commented 6 years ago

I'm not sure it's winnow, the Portland example you sent me works fine with the timeslider

On Wed, Apr 25, 2018, 9:40 PM Rich Gwozdz notifications@github.com wrote:

hmm, ok. I think I see what your are getting at. Maybe the timeslider is working fine, but the queries it generates aren't working in winnow. I have been assuming the time slider is not re-querying Koop on every slider event and it was doing the filtering on the fly, itself. I don't know that for sure though. We should confirm.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/koopjs/koop-provider-elasticsearch/issues/11#issuecomment-384494759, or mute the thread https://github.com/notifications/unsubscribe-auth/ADyxVPqGzYiwHmFcWxZVfsR4aYtpoNnFks5tsTOAgaJpZM4Tjb6l .

rgwozdz commented 6 years ago

The Portland example isn't Koop, its an AGOL service.

keithfraley commented 6 years ago

Ah, ok, #fingerscrossed

On Wed, Apr 25, 2018, 9:46 PM Rich Gwozdz notifications@github.com wrote:

The Portland example isn't Koop, its an AGOL service.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/koopjs/koop-provider-elasticsearch/issues/11#issuecomment-384495720, or mute the thread https://github.com/notifications/unsubscribe-auth/ADyxVMsK4tpnF1tR8UishnhwcovU-7MDks5tsTTpgaJpZM4Tjb6l .

rgwozdz commented 6 years ago

@keithfraley - I'm might not get to this for a while, so if you can attempt to debug and pass on anything you find, that would be great.

keithfraley commented 6 years ago

ok, understood, I will take a hack at it

On Thu, Apr 26, 2018 at 9:11 AM, Rich Gwozdz notifications@github.com wrote:

@keithfraley https://github.com/keithfraley - I'm probably won't be getting to this for a while, so if you can attempt to debug and pass on anything you find, that would be great.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/koopjs/koop-provider-elasticsearch/issues/11#issuecomment-384655310, or mute the thread https://github.com/notifications/unsubscribe-auth/ADyxVErt_267DuMc6BIl-kF9LWCJ6_uvks5tsdWbgaJpZM4Tjb6l .

rgwozdz commented 6 years ago

When I circle back around on this in the next day or two, I will get a working example going with the Craigslist provider and use that to document the feature.

keithfraley commented 6 years ago

esmodel insert right before return esQuery;

if (query.time !== undefined) {
        if (query.time.toString().includes('null') !== null) {
            let testu = query.time.split(',');
            let timeMin = testu[0] * 1;
            let timeMax = testu[1] * 1;

            // console.log(timeMin, timeMax);

            let strTimeQuery = '{ "range": {"' + strTimeColumn + '": { "gte": ' + timeMin + ', "lte":' + timeMax + '}}}';
            esQuery.body.query.bool.must.push(JSON.parse(strTimeQuery));
        }
    }
dhatcher commented 6 years ago

I was wondering if we had to handle this in the provider or if it got handled by koop. Does this work pretty well for you? If so I'll add this functionality into the provider with date parsing.

keithfraley commented 6 years ago

It works for certain, it would be good to leverage the appconfig file to set the timeslider date field, perhaps leverage the first date field listed per service

On May 1, 2018 8:28 AM, "Danny Hatcher" notifications@github.com wrote:

I was wondering if we had to handle this in the provider or if it got handled by koop. Does this work pretty well for you? If so I'll add this functionality into the provider with date parsing.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/koopjs/koop-provider-elasticsearch/issues/11#issuecomment-385670508, or mute the thread https://github.com/notifications/unsubscribe-auth/ADyxVKAyvwsmghoF2bwQNXppp5TgBNe2ks5tuGLogaJpZM4Tjb6l .

dhatcher commented 6 years ago

Time support has been added. I updated the readme as well with information on how this works. Let me know if you have any trouble.

keithfraley commented 6 years ago

awesome, thanks!

On Mon, May 7, 2018 at 9:26 AM, Danny Hatcher notifications@github.com wrote:

Time support has been added. I updated the readme as well with information on how this works. Let me know if you have any trouble.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/koopjs/koop-provider-elasticsearch/issues/11#issuecomment-387081962, or mute the thread https://github.com/notifications/unsubscribe-auth/ADyxVLlzbRCyx_1VBFqMUFUSzJibGRbHks5twFmLgaJpZM4Tjb6l .

keithfraley commented 6 years ago

brilliant, this works!