[SDK]: Fix Incorrect Lucene Query Conditionals in Query Builder
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 970
- Forks
- 486
- Avg merge
- 3d 33m
- Merged PRs (30d)
- 170
Description
Problem Statement
When using the @dotcms/client query builder with logical operators (OR, AND), the generated Lucene query is invalid or misleading.
Example
Code:
qb.field('conhost')
.equals(currentSiteValue?.identifier)
.or()
.equals(SYSTEM_HOST.identifier);
Current Output:
+conhost:ef0c8c29-9114-44f7-8c74-6e30b922d5c9 OR SYSTEM_HOST
Issues:
- Missing Parentheses – The conditional clause isn’t grouped, which may cause unexpected evaluation order.
- Missing Field Qualifier – The second condition (
SYSTEM_HOST) is not scoped to theconhostfield, making it a bare term.
Expected Output:
+(conhost:ef0c8c29-9114-44f7-8c74-6e30b922d5c9 OR conhost:SYSTEM_HOST)
This ensures both conditions apply correctly to the conhost field and preserves proper grouping.
Steps to Reproduce
- Use the
query builderin@dotcms/client. - Build a query with
.or()or.and(). - Inspect the generated Lucene query string.
- See the malformed conditional output.
Acceptance Criteria
- Queries generated with
.or()and.and()are properly wrapped in parentheses. - Field names are repeated for all clauses to ensure correct scoping.
- Unit tests added to verify conditional query generation with multiple fields and operators.
QA Notes
-
Test queries with nested conditionals, e.g.:
(A OR B) AND (C OR D)to confirm grouping and field scoping is correct.
-
Verify that queries mixing multiple fields still apply field qualifiers correctly.
-
Confirm no regressions in existing single-field queries.
dotCMS Version
main / trunk
Proposed Objective
Technical User Experience / Developer Experience
Proposed Priority
Priority 2 – Important
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the @dotcms/client query builder entry point and locate the logic that renders .or() and .and() clauses into Lucene query strings. Add unit tests for single-field, mixed-field, and nested conditionals, then verify that parentheses and field qualifiers match the expected output without changing existing single-field behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100