How is it possible to filter the categories on nodes received by getSubnodes API

Options

Hello how can we achieve the following behavior:

in OTCS we have the url below that provides us a list of nodes together with metadata and categories:

<serverurl>/api/v2/nodes/<nodeId>/nodes?fields=properties&fields=categories

There is a possibility to filter the properties like here :

<serverurl>/api/v2/nodes/<nodeId>/nodes?fields=categories&fields=properties{id,name,modify_date,create_date,owner,description,mime_type}

we tried to play with categories as with properties but the sample below doesn't work as we expect

<serverurl>/api/v2/nodes/<nodeId>/nodes?fields=categories{category_id}&fields=properties{id,name}

now the main question is below:

can we extract only the required categories/categories attributes as we can do with properties, or maybe there is another approach with OTCS REST API?

This is needed because returning all category values impacts the performance of the node obtaining.


Thanks and regards,

Evghenii

Tagged:

Comments

  • Hello Evghenil,

    I'm sorry, but the API doesn't allow you to filter categories

  • Hello @Matthew_Pinkney ,

    There is any existing API, or other methods, to return the custom metadata using REST without a big impact on the performance? If we include the Categories in the response for SUBNODES API, the response time is increasing dramatically from around 1second to 20-30 seconds!

    Any recommendation or best practice for this use case?

    Thank you,

    Ghenadie.

  • Ferdinand Prantl
    edited February 16, 2021 #4
    Options

    Requesting categories for every node in a result collection is meant for irregular data-mining tasks, not for live browsing. The expectation for response times of occasionally executed tools is not the same as when browsing containers in the UI.

    There are two options how to get live results filtered by categories. Both involve selecting only those attributes, which want to filter by, or which you want to obtain in the response:

    1. Configure custom columns based on the selected category attributes. Use where_* parameters to filter the child nodes.
    2. Configure displayable and queryable regions based for the selected category attributes in the search index. Use the /search resource to perform a search limited to a particular location and attribute values.
  • Thank you @Ferdinand Prantl,

    Actually, we thought about defining the custom "Columns". However, from the REST API, it is not very clear how we can filter by a custom column or how to retrieve specific columns.

    We were looking at the following API operation:

    GET https://localhost/alpha/cs.exe/api/v2/nodes/{id}/nodes?fields=properties{id,name,description}&fields=columns.

    Could you please help to identify the right parameters?


    Thank you,

    Ghenadie.

  • HI, i have a similar  question. Because i am searching for a way to shrink the result of the sort field.

    As example, i am searching only for the name.

    This is working but a little bid too much 

    https://my.content.server/OTCS/cs.exe/api/v1/nodes/17543158/nodes?fields=data
    

    Part of the response:

    {
       "data": [{
           "volume_id": -2000,
           "id": 17543159,
           "parent_id": 17543158,
           "user_id": 1000,
           "name": "This is my filename (100022)",
           "type": 144,
           "description": "",
           "create_date": "2020-12-04T08:35:00Z",
           "create_user_id": 1000,
           "modify_date": "2020-12-04T08:35:00Z",
           "modify_user_id": 1000,
           "reserved": false,
           "reserved_user_id": 0,
           "reserved_date": null
       }]
    }
    

    Any idea how i can achieve the a result like this with an additional parameter with a REST call?

    This would be perfect.

    {
       "name": "This is my filename (100022)"
    }
    
    

    All the best and have a wonderful evening.

    Christian

  • GhenadieS
    edited February 18, 2021 #7
    Options

    hi @Mchoeti ,

    you can shrink the result using following parameter in the second version of the API ( /api/v2/ ):

    fields=properties{id,name,description}


    Ghenadie.

  • @GhenadieS You can filter by a column value using something like ?fields=properties{wnf_att_47w_2} You can get the odd wnf* type number by doing /nodes/id?fields=columns to see what the column names are.

  • Hi all! Thanks for the information. I found out that this was working for me

    api/v2/nodes/18162208/nodes?fields=properties{create_date,id,name}&limit=5000 
    

    And of course do not forget to use api/v2/nodes

    All the best and thanks for the help

    Cheers Christian

  • @Matthew_Pinkney thanks for a good idea

    But we the api doesnt retrieve values from column we tried using something like this:

    &fields=columns

    and get the following response:

    {
      "data_type": -1,
      "key": "wnf_att_jmck_4",
      "name": "Document Type",
      "sort_key": "x514503"
    }
    

    after that I execute &fields=properties{id, name, wnf_att_jmck_4}

    and get the following


    "results": [
            {
                "data": {
                    "properties": {
                        "id": 512163,
                        "name": "0015019683"
                    }
                }
            },
            {
                "data": {
                    "properties": {
                        "id": 521035,
                        "name": "0015023296"
                    }
                }
            }
    

    So no actual column value is returned.


    Thanks and regards,

    Evghenii

  • Hmm, it worked on my machine :) . What version of CS are you using?

    if you make the api/v2/nodes/id/nodes?fields=columns&fields=properties{id,name,wnf_att_jmck_4} together I'm assuming it shoes the correct information in the column field group output.

  • Hello @Matthew_Pinkney we are using CS 20.3

    and we also were expecting something similar but it isn't, unfortunately.

    Here is one JSON Object that is retrieved from the search

    api/v2/nodes/477535/nodes?where_facet=495275:Not+Ready+for+Signature|Signed|Ready+for+Signature&limit=25&fields=columns&where_facet=495274:WZ&fields=properties{id,name,wnf_att_jmck_4}&sort=495273_5

    "results": [

            {

                "data": {

                    "columns": [

                        {

                            "data_type": 2,

                            "key": "type",

                            "name": "Type",

                            "sort_key": "type"

                        },

                        {

                            "data_type": -1,

                            "key": "name",

                            "name": "Name",

                            "sort_key": "name"

                        },

                        {

                            "data_type": -1,

                            "key": "size_formatted",

                            "name": "Size",

                            "sort_key": "size"

                        },

                        {

                            "data_type": 401,

                            "include_time": true,

                            "key": "modify_date",

                            "name": "Modified",

                            "sort_key": "modify_date"

                        }

                    ],

                    "properties": {

                        "id": 544650,

                        "name": "0015019683"

                    }

                }

            },