Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling statistics and object ID requests at an es level, not at a winnow level #22

Open
keithfraley opened this issue Nov 10, 2020 · 1 comment

Comments

@keithfraley
Copy link

keithfraley commented Nov 10, 2020

I have done some work in the old koop es provider to handle the query string statistics request within es, so that you can a true representation of unique values (for example) in order to do this we intercept the request coming from agol and modify the request going to es.

Example below, I have not looked yet into how to do this in the new es provider

`if (query.groupByFieldsForStatistics) {
            esQuery.body.aggs = {
                "uniqueValueCount": {
                    "cardinality": {
                        "field": query.groupByFieldsForStatistics + ".keyword"
                    }
                },
                [indexConfig.index]: {
                    "terms": {
                        "field": query.groupByFieldsForStatistics + ".keyword",
                        "size": 10000
                    }
                }
            };
        }
        if (query.objectIds) {
            esQuery.body.query.bool.filter = {
                ids: {}
            };


            esQuery.body.query.bool.filter.ids.values = [query.objectIds];
   `
`var whereParser = new WhereParser();
        if (where) {
            if (where.includes("UPPER")) {
                where = where.replace(/UPPER/g, '');
            }
            if (where.includes("objectid")) {
                where = where.replace("objectid", '_id');
            }
            if (where.includes("OBJECTID")) {
                where = where.replace("OBJECTID", '_id');
            }
            var boolClause = whereParser.parseWhereClause(where, indexConfig.dateFields, indexConfig.returnFields);
            if (boolClause) {
                if (boolClause.bool) {
                    if (boolClause.bool.must) {
                        boolClause.bool.must.push({ exists: { field: indexConfig.geometryField } });
                    }
                    else {
                        boolClause.bool.must = [
                            { exists: { field: indexConfig.geometryField } }
                        ];
                    }
                    esQuery.body.query = boolClause;
                }
                else {
                    esQuery.body.query.bool.must.push(boolClause);
                }
            }

        }`
@zakhtar1998
Copy link

@keithfraley were you able to setup koop successfully and view the json in the api? If so, it is possible if you can share your code or email address so i can reach out to you. Looking forward to hearing from you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants