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

Add "has" filter to cases #325

Closed
equinor-ruaj opened this issue Jun 4, 2024 · 1 comment · Fixed by #328
Closed

Add "has" filter to cases #325

equinor-ruaj opened this issue Jun 4, 2024 · 1 comment · Fixed by #328
Assignees

Comments

@equinor-ruaj
Copy link
Contributor

First version solution to: #324

First version to implement:
Add "has" keyword to case filter: filter cases where the case has at least one child with the specified "has" values.

cases = sumo.cases

cases = cases.filter(has={"data.content": "seismic", "data.time.t0.label": "base", "data.time.t1.label": "monitor"})

# With asset filter
cases = cases.filter(has={"data.content": "seismic", "data.time.t0.label": "base", "data.time.t1.label": "monitor"}, asset="Drogon")

-> cases == all cases that has child data matching the "has" filter
@roywilly
Copy link
Contributor

roywilly commented Jun 4, 2024

The corresponding query, from Raymond:

{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "data.content.keyword": {
              "value": "seismic"
            }
          }
        },
        {
          "term": {
            "data.time.t0.label.keyword": {
              "value": "base"
            }
          }
        },
        {
          "term": {
            "data.time.t1.label.keyword": {
              "value": "monitor"
            }
          }
        }
      ]
    }
  },
  "_source": ["data.time"],
  "aggs": {
    "case": {
      "composite": {
        "sources": [
          {
            "cases": {
              "terms": {
                "field": "fmu.case.uuid.keyword"
              }
            }
          }
        ],
        "size": 1000
      }
    }
  }, 
  "size": 1,
  "track_total_hits": true
}

@rwiker rwiker linked a pull request Jun 13, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants