-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Checked for duplicates
No - I haven't checked
π§βπ¬ User Persona(s)
User
πͺ Motivation
...so that I can more intuitively use the exists operator with a syntax that reads naturally in English (prefix notation) and combine it cleanly with the not operator.
π Additional Details
Feedback from the API Working Group meeting on 01-28-2026.
The current postfix syntax (implemented in #406) requires awkward constructions for negation:
- Current (postfix):
pds:Target/pds:name exists - Current negation:
not (pds:Investigation/pds:stop_date_time exists)
The new prefix syntax is more intuitive and reads naturally:
- New (prefix):
(exists pds:Target/pds:name) - New negation:
(not exists pds:Citation_Information/pds:author_list)
Examples of new syntax:
| Use Case | New Syntax |
|---|---|
| Check field exists | (exists pds:Target/pds:name) |
| Check field does NOT exist | (not exists pds:Investigation/pds:stop_date_time) |
| Regex pattern matching | (exists "pds:Target.*") |
| Combined with other conditions | (exists pds:Target/pds:name) and pds:Target/pds:type eq "Planet" |
| Complex query | (exists pds:Target/pds:name) and (not exists pds:Citation_Information/pds:author_list) |
Acceptance Criteria
Given I am querying the registry API
When I use (exists field_name) with the prefix syntax
Then the API returns only documents where the specified field exists and has a non-null/non-empty value
Given I am querying the registry API
When I use (not exists field_name) in my query
Then the API returns only documents where the specified field does not exist or is null/empty
Given I want to check for fields matching a regex pattern
When I use (exists "regex_pattern") with a quoted string
Then the API matches the regex against known field names and returns documents where any matched field exists
Given I combine exists with other query operators
When I use queries like (exists pds:Target/pds:name) and pds:Target/pds:type eq "Planet"
Then the API correctly applies both conditions and returns matching documents
βοΈ Engineering Details
This change requires updates to the ANTLR4 lexer grammar (Search.g4) in the lexer module:
-
Grammar Changes: Modify the
EXISTSrule from postfix to prefix notation:- Current grammar:
comparison : FIELD EXISTS | STRINGVAL EXISTS | ... - New grammar:
comparison : EXISTS FIELD | EXISTS STRINGVAL | ...
- Current grammar:
-
Listener Updates: Update
Antlr4SearchListener.javain the service module to handle the new parse tree structure whereEXISTSprecedes the field/pattern. -
NOT handling: Ensure
NOT EXISTSworks as a combined prefix operator (not justNOTwrapping the entire expression). -
Backward Compatibility: Determine whether to support both syntaxes during a transition period or deprecate the postfix syntax immediately.
-
Integration Tests: Update Postman collection in the
registryrepository with tests for the new syntax.
Files likely to be modified:
lexer/src/main/antlr4/gov/nasa/pds/api/registry/lexer/Search.g4service/src/main/java/gov/nasa/pds/api/registry/search/Antlr4SearchListener.java
π I&T
Update integration tests in the registry repository Postman collection to use the new prefix syntax for exists queries.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Status
Status