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

XPath Vars in Case Search #35561

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

XPath Vars in Case Search #35561

wants to merge 3 commits into from

Conversation

esoergel
Copy link
Contributor

@esoergel esoergel commented Dec 23, 2024

Product Description

Add a new magic case search parameter prefix, _xpath_var_ which can be used to declare template variables for use in _xpath_query expressions.

image

The evaluation layers are:

  • Process expressions as xpath in formplayer, which returns strings
  • Interpolate those strings with the provided variables (python string templating syntax)
  • Interpret those strings as CSQL expressions, returning an elasticsearch filter.

This seems like a pretty easy way to break up the massive xpath expressions USH projects use. I'd be interested to hear what app builders think of it before merging. It seemed easier to build than to write up and get feedback on in the abstract (only took a few hours of work). Some thoughts I have from brief testing are:

  • I don't love adding another layer of evaluation, especially as this doesn't solve all of the complexity problems
  • When testing it out, I realized that I really want the ability to use variables before the xpath evaluation step. This might be doable if we instead treat this as a macro expansion kind of thing during the build step, but that's a different approach entirely.
  • At present, variable declarations can't reference other variable declarations. That might be fine, but we could certainly consider adding that capability if it sounds useful. If default search filters have a deterministic ordering (I'm not certain whether that's the case), we could just interpolate top to bottom. Otherwise we'd have to do dependency tree stuff, which sounds nasty.
  • I still think a template function in xpath would be a huge win for relatively low effort. This operates similarly, but after the xpath evaluation is complete, so without that available context and a bit less cleanly, in my opinion.

Technical Summary

Feature Flag

Safety Assurance

Safety story

Automated test coverage

QA Plan

Rollback instructions

  • This PR can be reverted after deploy with no further considerations

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@esoergel esoergel force-pushed the es/case-search-vars branch from 1696757 to bdd76e7 Compare December 30, 2024 16:39
@esoergel esoergel changed the title Es/case search vars XPath Vars in Case Search Dec 30, 2024
@esoergel esoergel force-pushed the es/case-search-vars branch from bdd76e7 to 2ebfa6b Compare December 30, 2024 19:32
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 this pull request may close these issues.

1 participant