4

After much fiddling, I've finally got the Search Console API working. Unfortunately, I can't figure out how to add multiple OR filters. I presume this is what dimensionFilterGroups[].groupType will eventually be for, but 'or' is not yet an option.

Basically, how do you implement a series of filters where the results are returned when any are true?

I've tried the following, but none seem to work:

"dimensionFilterGroups": [
  {
    "filters": [
      {
        "dimension": 'query',
        "operator": 'equals',
        "expression": 'lockers'
      },
      {
        "dimension": 'query',
        "operator": 'equals',
        "expression": 'shelving'
      }
    ]
  }
]
"dimensionFilterGroups": [
  {
    "filters": [
      {
        "dimension": 'query',
        "operator": 'equals',
        "expression": 'lockers'
      }
    ],
    "filters": [
      {
        "dimension": 'query',
        "operator": 'equals',
        "expression": 'shelving'
      }
    ]
  }
]
"filters": [
  {
    "dimension": 'query',
    "operator": 'equals',
    "expression": 'lockers'
  },
  {
    "dimension": 'query',
    "operator": 'equals',
    "expression": 'shelving'
  }
]
curzmg
  • 647
  • 6
  • 11

2 Answers2

3

Unfortunately this still isn't supported according to the documentation.

dimensionFilterGroups[].groupType:

"Whether all filters in this group must return true ("and"), or one or more must return true (not yet supported)."

Source: https://developers.google.com/webmaster-tools/v3/searchanalytics/query

mpskovvang
  • 2,083
  • 2
  • 14
  • 19
0

I was trying to do the same. I guess the intuitive way would have been allowing other logical operators ("or", for example), but that's not possible. However, I achieved what I needed using the "includingRegex" filter operator. For example, for getting information only if the countries are either United States of America or Japan:

"dimensionFilterGroups": [
    {
      "groupType": "and",
      "filters": [
        {
          "dimension": "country",
          "operator": "includingRegex",
          "expression": "usa|jpn"
        }
      ]
    }
  ]