Filters with groupings

Description

Parameters of this type are used to filter data during report generation.

Available parameters are listed in the conditional_filters section of the GET /constructor_filters/api/ operation.

In the interface, these parameters are shown here:

All filters are classified into groups:

  • CLIDs and Sets.
  • Contracts.
  • Packs.

The actual content of the groups depends on the filters available to you.

Example of filters with groupings
{
  "id": "conditional_filters",
  "fields": [
    {
      "id": "CLIDs and Sets",
      "value": [
        {
          "id": "default_constructor_field_clid_container",
          "value": [
            {
              "id": "default_constructor_field_clid_group",
              "value": false,
              "label": "CLID"
            },
            {
              "id": "default_constructor_field_clid_operation",
              "value": "1",
              "choices": [
                {
                  "id": "1",
                  "label": "In list"
                },
                {
                  "id": "2",
                  "label": "Not in list"
                }
              ]
            },
            {
              "id": "default_constructor_field_clid",
              "value": null
            }
          ]
        },
        {
          "id": "default_constructor_field_clid_type_id_container",
          "value": [
            {
              "id": "default_constructor_field_clid_type_id_group",
              "value": false,
              "label": "Tool/CLID type"
            },
            {
              "id": "default_constructor_field_clid_type_id_operation",
              "value": "1",
              "choices": [
                {
                  "id": "1",
                  "label": "In list"
                },
                {
                  "id": "2",
                  "label": "Not in list"
                }
              ]
            },
            {
              "id": "default_constructor_field_clid_type_id",
              "value": [],
              "choices": [
                {
                  "id": "2023",
                  "label": "Alice"
                },
                {
                  "id": "1003",
                  "label": "Search widget"
                },
                {
                  "id": "5",
                  "label": "Home page"
                },
                {
                  "id": "1011",
                  "label": "Discovery revenue"
                },
                {
                  "id": "7",
                  "label": "Yandex button in Visual Bookmarks"
                },
                {
                  "id": "11",
                  "label": "Yandex button in the Opera side panel"
                },
                {
                  "id": "21",
                  "label": "Market. Advisor for websites"
                      },
                      {
                        "id": "27",
                        "label": "Partner links"
                      },
                      {
                        "id": "12",
                        "label": "Search in the Opera side panel"
                      },
                      {
                        "id": "9",
                        "label": "Search in the browser address bar"
                      },
                      {
                        "id": "1002",
                        "label": "Search in the notification panel"
                      },
                      {
                        "id": "100003",
                        "label": "Search in the search form on the partner site"
                      },
                      {
                        "id": "8",
                        "label": "Search form in Visual Bookmarks"
                      },
                      {
                        "id": "6",
                        "label": "Search form in the browser"
                      },
                      {
                        "id": "1004",
                        "label": "Search form in the app"
                      },
                      {
                        "id": "100016",
                        "label": "Yandex Games link"
                      },
                      {
                        "id": "20",
                        "label": "Link to Yandex Market"
                      },
                      {
                        "id": "25",
                        "label": "Link to Yandex Market from Adviser"
                      },
                      {
                        "id": "15",
                        "label": "Link to Yandex from the \"Favorites\" Bookmarks bar"
                      },
                      {
                        "id": "1",
                        "label": "Unique install"
                      }
                    ]
                  }
                ]
              },
              {
                "id": "default_constructor_field_set_domain_container",
                "value": [
                  {
                    "id": "default_constructor_field_set_domain_group",
                    "value": false,
                    "label": "Set domain"
                  },
                  {
                    "id": "default_constructor_field_set_domain_operation",
                    "value": "3",
                    "choices": [
                      {
                        "id": "3",
                        "label": "Contains"
                      },
                      {
                        "id": "4",
                        "label": "Does not contain"
                      }
                    ]
                  },
                  {
                    "id": "default_constructor_field_set_domain",
                    "value": null
                  }
                ]
              },
              {
                "id": "default_constructor_field_set_caption_container",
                "value": [
                  {
                    "id": "default_constructor_field_set_caption_group",
                    "value": false,
                    "label": "Set name"
                  },
                  {
                    "id": "default_constructor_field_set_caption_operation",
                    "value": "3",
                    "choices": [
                      {
                        "id": "3",
                        "label": "Contains"
                      },
                      {
                        "id": "4",
                        "label": "Does not contain"
                      }
                    ]
                  },
                  {
                    "id": "default_constructor_field_set_caption",
                    "value": null
                  }
                ]
              },
              {
                "id": "default_constructor_field_set_id_container",
                "value": [
                  {
                    "id": "default_constructor_field_set_id_group",
                    "value": false,
                    "label": "Set ID"
                  },
                  {
                    "id": "default_constructor_field_set_id_operation",
                    "value": "1",
                    "choices": [
                      {
                        "id": "1",
                        "label": "In list"
                      },
                      {
                        "id": "2",
                        "label": "Not in list"
                      }
                    ]
                  },
                  {
                    "id": "default_constructor_field_set_id",
                    "value": null
                  }
                ]
              }
            ],
            "label": "CLIDs and sets"
          },
          {
            "id": "Contracts",
            "value": [
              {
                "id": "default_constructor_field_external_id_parent_container",
                "value": [
                  {
                    "id": "default_constructor_field_external_id_parent_group",
                    "value": false,
                    "label": "External ID"
                  },
                  {
                    "id": "default_constructor_field_external_id_parent_operation",
                    "value": "1",
                    "choices": [
                      {
                        "id": "1",
                        "label": "In list"
                      },
                      {
                        "id": "2",
                        "label": "Not in list"
                      },
                      {
                        "id": "3",
                        "label": "Contains"
                      },
                      {
                        "id": "4",
                        "label": "Does not contain"
                      }
                    ]
                  },
                  {
                    "id": "default_constructor_field_external_id_parent",
                    "value": null
                  }
                ]
              }
            ],
            "label": "Contracts"
          },
          {
            "id": "Packs",
            "value": [
              {
                "id": "default_constructor_field_vid_container",
                "value": [
                  {
                    "id": "default_constructor_field_vid_group",
                    "value": false,
                    "label": "VID"
                  },
                  {
                    "id": "default_constructor_field_vid_operation",
                    "value": "1",
                    "choices": [
                      {
                        "id": "1",
                        "label": "In list"
                      },
                      {
                        "id": "2",
                        "label": "Not in list"
                      }
                    ]
                  },
                  {
                    "id": "default_constructor_field_vid",
                    "value": null
                  }
                ]
              },
              {
                "id": "default_constructor_field_soft_id_container",
                "value": [
                  {
                    "id": "default_constructor_field_soft_id_group",
                    "value": false,
                    "label": "Soft"
                  },
                  {
                    "id": "default_constructor_field_soft_id_operation",
                    "value": "1",
                    "choices": [
                      {
                        "id": "1",
                        "label": "In list"
                      },
                      {
                        "id": "2",
                        "label": "Not in list"
                      }
                    ]
                  },
                  {
                    "id": "default_constructor_field_soft_id",
                    "value": [],
                    "choices": [
                      {
                        "id": "999",
                        "label": "Minorities"
                      },
                      {
                        "id": "1002",
                        "label": "Mobile Opera"
                      },
                      {
                        "id": "3",
                        "label": "Opera"
                      },
                      {
                        "id": "1013",
                        "label": "Browser settings"
                      },
                      {
                        "id": "11",
                        "label": "Yandex app"
                      },
                      {
                        "id": "1025",
                        "label": "Adviser. Browser extension"
                      },
                      {
                        "id": "1000",
                        "label": "Third-party site"
                      },
                      {
                        "id": "8",
                        "label": "Third-party soft"
                      },
                      {
                        "id": "1170",
                        "label": "Yandex Games"
                      },
                      {
                        "id": "1046",
                        "label": "Yandex Market (marketplace)"
                      },
                      {
                        "id": "1033",
                        "label": "Yandex Market (ad platform)"
                      }
                    ]
                  }
                ]
              },
              {
                "id": "default_constructor_field_pack_id_container",
                "value": [
                  {
                    "id": "default_constructor_field_pack_id_group",
                    "value": false,
                    "label": "Pack ID"
                  },
                  {
                    "id": "default_constructor_field_pack_id_operation",
                    "value": "1",
                    "choices": [
                      {
                        "id": "1",
                        "label": "In list"
                      },
                      {
                        "id": "2",
                        "label": "Not in list"
                      }
                    ]
                  },
                  {
                    "id": "default_constructor_field_pack_id",
                    "value": null
                  }
                ]
              },
              {
                "id": "default_constructor_field_pack_caption_container",
                "value": [
                  {
                    "id": "default_constructor_field_pack_caption_group",
                    "value": false,
                    "label": "Pack name"
                  },
                  {
                    "id": "default_constructor_field_pack_caption_operation",
                    "value": "3",
                    "choices": [
                      {
                        "id": "3",
                        "label": "Contains"
                      },
                      {
                        "id": "4",
                        "label": "Does not contain"
                      }
                    ]
                  },
                  {
                    "id": "default_constructor_field_pack_caption",
                    "value": null
                  }
                ]
              },
              {
                "id": "default_constructor_field_pack_traffic_id_container",
                "value": [
                  {
                    "id": "default_constructor_field_pack_traffic_id_group",
                    "value": false,
                    "label": "Platform"
                  },
                  {
                    "id": "default_constructor_field_pack_traffic_id_operation",
                    "value": "1",
                    "choices": [
                      {
                        "id": "1",
                        "label": "In list"
                      },
                      {
                        "id": "2",
                        "label": "Not in list"
                      }
                    ]
                  },
                  {
                    "id": "default_constructor_field_pack_traffic_id",
                    "value": "-1",
                    "choices": [
                      {
                        "id": "-1",
                        "label": "All"
                      },
                      {
                        "id": "1",
                        "label": "Desktop"
                      },
                      {
                        "id": "4",
                        "label": "Mobile"
                      }
                    ]
                  }
                ]
              },
              {
                "id": "default_constructor_field_pack_country_id_container",
                "value": [
                  {
                    "id": "default_constructor_field_pack_country_id_group",
                    "value": false,
                    "label": "Pack country"
                  },
                  {
                    "id": "default_constructor_field_pack_country_id_operation",
                    "value": "1",
                    "choices": [
                      {
                        "id": "1",
                        "label": "In list"
                      },
                      {
                        "id": "2",
                        "label": "Not in list"
                      }
                    ]
                  },
                  {
                    "id": "default_constructor_field_pack_country_id",
                    "value": [],
                    "choices": [
                      {
                        "id": "8",
                        "label": "Earth"
                      },
                      {
                        "id": "6",
                        "label": "CUBR"
                      },
                      {
                        "id": "1",
                        "label": "Russia"
                      },
                      {
                        "id": "3",
                        "label": "Russia+CIS"
                      },
                      {
                        "id": "7",
                        "label": "Russia+CIS+Turkey"
                      },
                      {
                        "id": "4",
                        "label": "Turkey"
                      }
                    ]
                  }
                ]
              },
              {
                "id": "default_constructor_field_pack_domain_container",
                "value": [
                  {
                    "id": "default_constructor_field_pack_domain_group",
                    "value": false,
                    "label": "Pack site/domain"
                  },
                  {
                    "id": "default_constructor_field_pack_domain_operation",
                    "value": "3",
                    "choices": [
                      {
                        "id": "3",
                        "label": "Contains"
                      },
                      {
                        "id": "4",
                        "label": "Does not contain"
                      }
                    ]
                  },
                  {
                    "id": "default_constructor_field_pack_domain",
                    "value": null
                  }
                ]
              }
            ],
            "label": "Packs"
          }
        ]
      },
      {
        "id": "currency_converter",
        "fields": [
          {
            "id": "convert_currency_to_field",
            "value": "-1",
            "choices": [
              {
                "id": "-1",
                "label": "In transaction currency"
              },
              {
                "id": "1",
                "label": "US dollar"
              },
              {
                "id": "2",
                "label": "Russian ruble"
              },
              {
                "id": "3",
                "label": "Euro"
              }
            ]
          }
        ]
      }
    ]
  },
  "result": "ok"
}

Types of filters

  1. Filter with a string value — Each acceptable filter value is separated from others by a delimiter (space, comma, semicolon). For example, instead of 222342, 2342123, 6546423, you can simply use 6546423. The difference is in the default value — null.
  2. Selector — Strictly one id out of the acceptable values. All the acceptable values are specified in the choices field (for example, the default_constructor_field_pack_traffic_id filter from the example above). The difference is that it always has one of the default values.
  3. Multiselector — One or more id values from the list in the choices field (for example, the default_constructor_field_pack_country_id filter from the example above). The difference is that the default value is []. It includes a list of id values even if you only select one, for example: ["2", "4", "1"] or ["3"].

List of all operations

  • “IN” (In the list) — The operation is used for arrays. The report is generated using values that are included in the specified parameter value.
  • “NOT IN” (Not in the list) — The operation is used for arrays. The report is generated using values that are not included in the specified parameter value.
  • “LIKE” (Contains) — The operation is used for scalar values. The report is generated using parameter values that are included in the specified substring.
  • “NOT LIKE” (Not in list) — The operation is used for scalar values. The report is generated using parameter values except the values that are included in the specified substring.

Filter example

{
  "id": "default_constructor_field_pack_id_container",
  "value": [
    {
      "id": "default_constructor_field_pack_id_group",
      "value": false,
      "label": "Pack ID"
    },
    {
      "id": "default_constructor_field_pack_id_operation",
      "value": "1",
      "choices": [
        {
          "id": "1",
          "label": "In list"
        },
        {
          "id": "2",
          "label": "Not in list"
        }
      ]
    },
    {
      "id": "default_constructor_field_pack_id",
      "value": null
    }
  ]
}

Like other filters, this one is a container with default_constructor_field_pack_id_container as the ID. It includes three sections:

  1. *_group — The section for grouping by a field. The grouping is disabled by default (the value is false). If you enable grouping, a column corresponding to the filter is added to the report.

  2. *_operation — The operation section. The set of operations is different for each filter. To select an operation for the filter, use the operation ID as the value in this section.

    For example, if you need the “Not in list” operation, use the value 2. If you don't select an operation, the default operation is applied. In this case, it will have the id of 1 — “In list”.

  3. The filter value section is used to set filtered values. Acceptable filter values depend on the filter type.

    There are different types of filters, but they are the same as their counterparts in the interface. In this case, the filter by Pack ID accepts a string value, with every acceptable Pack ID being separated from others by a delimiter (space, comma, semicolon). For example, instead of 222342, 2342123, 6546423 you can simply use 6546423.

If you use a value in the filter value section but omit true in the grouping section, the data for the report will be filtered by the specified value, but the report won't include the filter column. All filters are combined using AND similarly to filters in the interface.

How to fill out a request

Example 1

You only need to filter by Pack ID. In this case, you can replace the conditional_filters section as follows:

Example code
{
  "id": "conditional_filters",
  "fields": [
    {
      "id": "Packs",
      "value": [
        {
          "id": "default_constructor_field_pack_id_container",
          "value": [
            {
              "id": "default_constructor_field_pack_id",
              "value": "32423, 23423"
            }
          ]
        }
      ]
    }
  ]
}

Example 2

You only need to filter and group by Pack ID. In this case, you can replace the conditional_filters section as follows:

Example code
{
  "id": "conditional_filters",
  "fields": [
    {
      "id": "Packs",
      "value": [
        {
          "id": "default_constructor_field_pack_id_container",
          "value": [
            {
              "id": "default_constructor_field_pack_id_group",
              "value": true
            },
            {
              "id": "default_constructor_field_pack_id",
              "value": "32423, 23423"
            }
          ]
        }
      ]
    }
  ]
}

Example 3

You need to filter by Pack ID, group by CLID, filter using the “Not in list” operation, and group by “Tool/CLID type”. In this case, the conditional_filters section will be as follows:

Example code
{
  "id": "conditional_filters",
  "fields": [
    {
      "id": "Packs",
      "value": [
        {
          "id": "default_constructor_field_pack_id_container",
          "value": [
            {
              "id": "default_constructor_field_pack_id",
              "value": "32423, 23423"
            }
          ]
        }
      ]
    },
    {
      "id": "CLIDs and Sets",
      "value": [
        {
          "id": "default_constructor_field_clid_container",
          "value": [
            {
              "id": "default_constructor_field_clid_group",
              "value": true
            }
          ]
        },
        {
          "id": "default_constructor_field_clid_type_id_container",
          "value": [
            {
              "id": "default_constructor_field_clid_type_id_group",
              "value": true
            },
            {
              "id": "default_constructor_field_clid_type_id_operation",
              "value": "2"
            },
            {
              "id": "default_constructor_field_clid_type_id",
              "value": [
                "1003",
                "5",
                "100003"
              ]
            }
          ]
        }
      ]
    }
  ]
}
Previous