Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document examples of filtering output in an operation chain #276

Open
n3101 opened this issue May 3, 2022 · 1 comment
Open

Document examples of filtering output in an operation chain #276

n3101 opened this issue May 3, 2022 · 1 comment
Labels
feature A new feature/component for the documentation
Milestone

Comments

@n3101
Copy link
Contributor

n3101 commented May 3, 2022

Today a user asked for help constructing an operation chain where the returned results were filtered using an OR predicate. @GCHQDev404 constructed the code fragment below; which may be useful when rewriting the doc for Gaffer 2.0:

{
  "class" : "uk.gov.gchq.gaffer.operation.OperationChain",
  "operations" : [ {
    "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements"
  }, {
    "class" : "uk.gov.gchq.gaffer.operation.impl.function.Filter",
    "edges" : {
      "edgeGroupName" : {
        "predicates" : [ {
          "selection" : [ "selection1" ],
          "predicate" : {
            "class" : "uk.gov.gchq.koryphe.impl.predicate.Or",
            "predicates" : [ {
              "class" : "uk.gov.gchq.koryphe.impl.predicate.CollectionContains",
              "value" : 1111
            }, {
              "class" : "uk.gov.gchq.koryphe.impl.predicate.CollectionContains",
              "value" : 3333
            } ]
          }
        } ]
      }
    }
  } ]
}
@n3101
Copy link
Contributor Author

n3101 commented May 4, 2022

Or a more complicated example using TupleAdaptedPredicate for multiple fields:

{
    "class": "uk.gov.gchq.gaffer.operation.OperationChain",
    "operations": [
        {
            "class": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements",
            "options": {
                "gaffer.federatedstore.operation.graphIds": "graphSource1"
            }
        },
        {
            "class": "uk.gov.gchq.gaffer.operation.impl.function.Filter",
            "edges": {
                "edgeGroupName": {
                    "groupBy": [
                        "types"
                    ],
                    "predicates": [
                        {
                            "selection": [
                                "names",
                                "types"
                            ],
                            "predicate": {
                                "class": "uk.gov.gchq.koryphe.impl.predicate.Or",
                                "predicates": [
                                    {
                                        "class": "uk.gov.gchq.koryphe.tuple.predicate.TupleAdaptedPredicate",
                                        "selection": [
                                            0
                                        ],
                                        "predicate": {
                                            "class": "uk.gov.gchq.koryphe.impl.predicate.CollectionContains",
                                            "value": "jane"
                                        }
                                    },
                                    {
                                        "class": "uk.gov.gchq.koryphe.tuple.predicate.TupleAdaptedPredicate",
                                        "selection": [
                                            1
                                        ],
                                        "predicate": {
                                            "class": "uk.gov.gchq.koryphe.impl.predicate.CollectionContains",
                                            "value": "person"
                                        }
                                    }
                                ]
                            }
                        }
                    ]
                }
            },
            "options": {
                "gaffer.federatedstore.operation.graphIds": "graphSource1"
            }
        }
    ]
}

@GCHQDeveloper314 GCHQDeveloper314 added this to the v2.0.0 milestone Nov 2, 2022
@GCHQDeveloper314 GCHQDeveloper314 added the enhancement Improvement to an existing part of the documentation label Nov 2, 2022
@GCHQDeveloper314 GCHQDeveloper314 added feature A new feature/component for the documentation and removed enhancement Improvement to an existing part of the documentation labels Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature/component for the documentation
Projects
None yet
Development

No branches or pull requests

2 participants