Giter VIP home page Giter VIP logo

Comments (14)

cigolpl avatar cigolpl commented on June 20, 2024

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 ?

from itemsapi.

athlonUA avatar athlonUA commented on June 20, 2024

Great decision! The main thing that it affected the performance

from itemsapi.

athlonUA avatar athlonUA commented on June 20, 2024

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

from itemsapi.

cigolpl avatar cigolpl commented on June 20, 2024

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 ?

from itemsapi.

athlonUA avatar athlonUA commented on June 20, 2024

👍 Great!

from itemsapi.

pilot avatar pilot commented on June 20, 2024

@cigolpl it would be cool!

from itemsapi.

cigolpl avatar cigolpl commented on June 20, 2024

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

from itemsapi.

athlonUA avatar athlonUA commented on June 20, 2024

@cigolpl cool! i check it today!

from itemsapi.

athlonUA avatar athlonUA commented on June 20, 2024

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"
}

from itemsapi.

cigolpl avatar cigolpl commented on June 20, 2024

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 ?

from itemsapi.

athlonUA avatar athlonUA commented on June 20, 2024

Great! This works nice for now! 👍

from itemsapi.

cigolpl avatar cigolpl commented on June 20, 2024

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 ?

from itemsapi.

athlonUA avatar athlonUA commented on June 20, 2024

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

from itemsapi.

cigolpl avatar cigolpl commented on June 20, 2024

Oo, that's really cool

from itemsapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.