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

Is it possible to disable aggregation key in schema during request? #158

Closed
athlonUA opened this issue Sep 28, 2016 · 14 comments
Closed

Is it possible to disable aggregation key in schema during request? #158

athlonUA opened this issue Sep 28, 2016 · 14 comments

Comments

@athlonUA
Copy link

The problem is about how to temporary disable aggregation processing during requests? The aggregation takes a lot of time and in some requests i want to disable it

@cigolpl
Copy link
Member

cigolpl commented Sep 28, 2016

Hi Alex, it is not possible now but definitely could be useful.
What would you say for providing the list which aggregations should be loaded in GET query (i.e. load_aggs=brand,model,tags or load_aggs=), is it ok ?

@athlonUA
Copy link
Author

Great decision! The main thing that it affected the performance

@athlonUA
Copy link
Author

For me, when i remove aggregation list from schema the time response is about 45 ms and with aggregation list this value is about 1,5 seconds And it would be cool to provide the list which aggregations should be loaded in GET query

@cigolpl
Copy link
Member

cigolpl commented Sep 28, 2016

Yeah, definitely. 1.5 seconds is too long if 45 ms is possible. I have it on my ToDo list. I will implement that probably by Friday. Is it "asap" for you ?

@athlonUA
Copy link
Author

👍 Great!

@pilot
Copy link

pilot commented Sep 28, 2016

@cigolpl it would be cool!

@cigolpl
Copy link
Member

cigolpl commented Sep 29, 2016

@athlonUA @pilot it is done. please let me know if that works for you

@athlonUA
Copy link
Author

@cigolpl cool! i check it today!

@athlonUA
Copy link
Author

athlonUA commented Oct 3, 2016

hi @cigolpl If i make search with no aggregations like this /api/v1/items/products?load_aggs= i receive the error like this

{
    error: "Cannot read property 'category_tree' of undefined"
}

I receive this error when i make request with aggregation like /api/v1/items/products?load_aggs=brand also.

From logs:

error: [TypeError: Cannot read property 'category_tree' of undefined] 'TypeError: Cannot read property \'category_tree\' of undefined\n    at /var/www/example.com/node_modules/itemsapi/src/helpers/search.js:17:54\n    at arrayMap (/var/www/example.com/node_modules/itemsapi/node_modules/lodash/index.js:1406:25)\n    at Function.map (/var/www/example.com/node_modules/itemsapi/node_modules/lodash/index.js:6710:14)\n    at getAggregationsResponse (/var/www/example.com/node_modules/itemsapi/src/helpers/search.js:16:24)\n    at Object.searchConverter (/var/www/example.com/node_modules/itemsapi/src/helpers/search.js:107:23)\n    at /var/www/example.com/node_modules/itemsapi/src/services/search.js:193:27\n    at tryCatcher (/var/www/example.com/node_modules/itemsapi/node_modules/bluebird/js/release/util.js:16:23)\n    at Promise._settlePromiseFromHandler (/var/www/example.com/node_modules/itemsapi/node_modules/bluebird/js/release/promise.js:510:31)\n    at Promise._settlePromise (/var/www/example.com/node_modules/itemsapi/node_modules/bluebird/js/release/promise.js:567:18)\n    at Promise._settlePromise0 (/var/www/example.com/node_modules/itemsapi/node_modules/bluebird/js/release/promise.js:612:10)\n    at Promise._settlePromises (/var/www/example.com/node_modules/itemsapi/node_modules/bluebird/js/release/promise.js:691:18)\n    at Async._drainQueue (/var/www/example.com/node_modules/itemsapi/node_modules/bluebird/js/release/async.js:138:16)\n    at Async._drainQueues (/var/www/example.com/node_modules/itemsapi/node_modules/bluebird/js/release/async.js:148:10)\n    at Immediate.Async.drainQueues [as _onImmediate] (/var/www/example.com/node_modules/itemsapi/node_modules/bluebird/js/release/async.js:17:14)\n    at processImmediate [as _immediateCallback] (timers.js:383:17)'

The collections.json file i have

[
    {
        "name": "products",
        "project": "example",
        "schema": {
            "brand": {
                "type": "string",
                "index": "not_analyzed"
            },
            "category_identificator": {
                "type": "string",
                "index": "not_analyzed"
            },
            "id": {
                "type": "string",
                "index": "not_analyzed"
            },
            "name": {
                "type": "string"
            }
        },
        "aggregations": [
            {
                "name": "category_tree",
                "type": "terms",
                "field": "category_identificator",
                "size": 40,
                "title": "Categories"
            },
            {
                "name": "brand",
                "type": "terms",
                "field": "brand",
                "size": 40,
                "title": "Brands"
            }
        ],
        "table": {
            "fields": [
                "category_identificator",
                "name",
                "brand"
            ]
        }
    }
]

I also tried to remove category_tree aggregation but the server show the error response

{
    error: "Cannot read property 'brand' of undefined"
}

@cigolpl
Copy link
Member

cigolpl commented Oct 3, 2016

Hi Alex, thanks for feedback!

Could you temporary change your aggregations for:

"aggregations": {
    "category_tree": {
        "type": "terms",
        "field": "category_identificator",
        "size": 40,
        "title": "Categories"
    },
    "brand": {
        "type": "terms",
        "field": "brand",
        "size": 40,
        "title": "Brands"
    }
}

and see if /api/v1/items/products?load_aggs=brand works now ?

@athlonUA
Copy link
Author

athlonUA commented Oct 3, 2016

Great! This works nice for now! 👍

@cigolpl
Copy link
Member

cigolpl commented Oct 3, 2016

Great but there can be a small problem. If you define aggregations as an object it works but your json response will be slightly different than with aggregations as an array and your app can stop working properly.

I've made a mistake some time ago introducing aggregations as an array because we need now to support both types in development and tests. It was my fault.

How is your app working with that new temporary configuration ?

@athlonUA
Copy link
Author

athlonUA commented Oct 3, 2016

All works perfectly, i didn't get any problems after defining aggregations as an object

@cigolpl
Copy link
Member

cigolpl commented Oct 3, 2016

Oo, that's really cool

@cigolpl cigolpl closed this as completed Oct 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants