OpenSearch: unique-field validation query fails with 'all shards failed' under phase 2
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 970
- Forks
- 486
- Avg merge
- 3d 33m
- Merged PRs (30d)
- 170
Description
Found during the phase-2 (dual-write, reads from OpenSearch) integration triage (#36501), while debugging a different test. Captured from a healthy phase-2 run (OS reachable, PHASE_2 active).
Symptom
Unique-field validation issues a search that fails against OpenSearch with search_phase_execution_exception: all shards failed. ContentFactoryIndexOperationsOS.cachedIndexSearch catches it and returns ERROR_HIT (total=0), so the failure is silent (validation may then behave as if no duplicate exists).
Captured query (OS, phase 2)
{"_source":{"includes":["inode","identifier"]},
"query":{"query_string":{"query":
"+structurename:testvarname<ts> +languageid:1 +( +conhost:<siteHash>testvarname<ts>.testfieldvarname<ts>_sha256:<valueHash> )"}},
"size":10000,"sort":[{"_score":{"order":"desc"}},{"moddate":{"order":"desc"}}],
"timeout":"15s","track_total_hits":10000000}
The <contentTypeVar>.<fieldVar>_sha256 term targets a dynamic unique-hash field. Likely cause: that field isn't mapped (or the query_string parses the dotted _sha256 term in a way OpenSearch rejects), producing a per-shard query_shard_exception → "all shards failed". The ES path handles the same query in phase 0/1.
Where
- Query build/translation:
dotCMS/src/main/java/com/dotcms/content/index/opensearch/ContentFactoryIndexOperationsOS(query_string translation) and the OS content mapping / dynamic templates (os-content-settings.json). - Silent swallow:
ContentFactoryIndexOperationsOS.cachedIndexSearch→ERROR_HIT (total=0)(see also #36577).
Impact
Unique-field uniqueness checks rely on this search; if it silently returns 0 under phase 2, duplicate detection could be bypassed. Needs: (1) make the unique-hash field/query valid on OS (mapping or query translation), (2) stop swallowing a real search error as 0 results under phase 2 (#36577).
Related: #36501, #36577.
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 dotCMS/src/main/java/com/dotcms/content/index/opensearch/ContentFactoryIndexOperationsOS, tracing query_string translation and cachedIndexSearch, then inspect os-content-settings.json for the dynamic unique-hash mapping. Reproduce or inspect the captured phase-2 query and verify that unique-field validation no longer produces an all-shards-failed error or treats a real search error as zero results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100