Filter to exclude

Hello,

I am trying to make a filter to exclude one category. The field named “categories” contain cat_1, cat_2, cat_3, … How to make a filter from this category to exclude one of them? let say, exclude cat_1

This should work (not tested):

{
  "filter": {
    "categories": {
      "$not": "cat_1"
    }
  }
}

edit: Changed $nin to $not. $nin can be used to find a non matching string field with an array as search term.

1 Like

Hi @raffaelj,

I tested it. I change $nin into $not. It’s worked.
Thank you, Sir!!

Is it possible to filter by collectionlink?
i have a collection where inside i use collectionlink field and i would like to filter by those.

"published": "Published",
    "title": "Image 4 - [Single]",
    "caption": "Caption single image",
    "keywords": [
        {
            "_id": "5e74d60639353163be0000ea",
            "link": "keywords",
            "display": "Keyword 1"
        },
        {
            "_id": "5e74d614316139deae0001a5",
            "link": "keywords",
            "display": "Keyword 2"
        }
    ],
    "color": {
        "_id": "5e735ca56362308892000074",
        "link": "colors",
        "display": "#fff800"
    },
    "_mby": "5e6a2353633138545a000121",
    "_by": "5e6a2353633138545a000121",
    "_modified": 1585646352,
    "_created": 1584720385,
    "permalink": "image-4-single",
    "_id": "5e74ea01383965c5ce000021",
    "priority": "6"
}

Example I would like to filter by keywords = Keyword 1

thanks

Collection links are more complicated. It’s easy to filter strings and arrays, but not arrays of objects, especially if you use SQLite and not MongoDB. I don’t have much time right now, but maybe you find a solution here: Search results for 'filter collection link' - Cockpit Community