Problem Statement
Confirmed platform-wide regression. The /api/es/search and /api/es/raw REST endpoints return HTTP 500 with the error:
JSON does not allow non-finite numbers.
This affects any consumer whose search results carry a non-finite _score — most commonly:
- queries that sort by a field (Elasticsearch sets
_score to NaN unless track_scores=true),
- filter /
constant_score / aggregation-only contexts.
It is not content-specific (reproducible on Production, Staging, and UAT with unchanged content) and hits built-in features such as Site Search as well as custom /api/es/search calls.
Root cause
Introduced by PR #36398 (route /api/es/raw & /api/es/search through phase-aware SearchAPI), first released in v26.07.04-01.
The endpoints were rewritten to rebuild the legacy Elasticsearch-wire response via dotCMS's com.dotmarketing.util.json.JSONObject (ESContentResourcePortlet.toLegacyEsJson → hitsToLegacyJson). The per-hit score is added with a raw float:
// ESContentResourcePortlet.hitsToLegacyJson
.put("_score", hit.getScore()) // hit.getScore() can be Float.NaN
JSONObject.put(...) runs testValidity(), which throws on non-finite values:
// com.dotmarketing.util.json.JSONObject.testValidity
if (((Float) o).isInfinite() || ((Float) o).isNaN())
throw new JSONException("JSON does not allow non-finite numbers.");
The previous implementation returned Elasticsearch's native JSON (SearchResponse.toString()), which serializes NaN as null — so the error did not occur before the cutover.
Steps to Reproduce
POST /api/es/search with a query that sorts by a field (e.g. a date field) and does not set track_scores: true — or a plain terms search combined with a content-type aggregation.
- Observe the response.
Actual: HTTP 500 — JSON does not allow non-finite numbers.
Expected: valid JSON with "_score": null for non-scored hits, matching the pre-regression Elasticsearch-native wire format.
Acceptance Criteria
dotCMS Version
Severity
High - Major functionality broken (search endpoints and Site Search fail in production; not content-related).
Links
Affected file: dotCMS/src/main/java/com/dotcms/rest/elasticsearch/ESContentResourcePortlet.java
Problem Statement
Confirmed platform-wide regression. The
/api/es/searchand/api/es/rawREST endpoints return HTTP 500 with the error:This affects any consumer whose search results carry a non-finite
_score— most commonly:_scoretoNaNunlesstrack_scores=true),constant_score/ aggregation-only contexts.It is not content-specific (reproducible on Production, Staging, and UAT with unchanged content) and hits built-in features such as Site Search as well as custom
/api/es/searchcalls.Root cause
Introduced by PR #36398 (route
/api/es/raw&/api/es/searchthrough phase-aware SearchAPI), first released in v26.07.04-01.The endpoints were rewritten to rebuild the legacy Elasticsearch-wire response via dotCMS's
com.dotmarketing.util.json.JSONObject(ESContentResourcePortlet.toLegacyEsJson→hitsToLegacyJson). The per-hit score is added with a rawfloat:JSONObject.put(...)runstestValidity(), which throws on non-finite values:The previous implementation returned Elasticsearch's native JSON (
SearchResponse.toString()), which serializesNaNasnull— so the error did not occur before the cutover.Steps to Reproduce
POST /api/es/searchwith a query that sorts by a field (e.g. a date field) and does not settrack_scores: true— or a plaintermssearch combined with a content-type aggregation.Actual: HTTP 500 —
JSON does not allow non-finite numbers.Expected: valid JSON with
"_score": nullfor non-scored hits, matching the pre-regression Elasticsearch-native wire format.Acceptance Criteria
/api/es/searchand/api/es/rawreturn valid JSON (HTTP 200) for field-sorted queries that produceNaNscores.NaN/Infinity)_scorevalues serialize asnull, preserving the legacy Elasticsearch-wire shape.float/doublewritten into the responseJSONObject(per-hit_scoreand the suggesterscorefields).ContentSearchResponsewhose hit carriesFloat.NaNthroughtoLegacyEsJsonand asserts valid JSON with"_score": null(instead of throwing).dotCMS Version
main.release-26.07.06-01.Severity
High - Major functionality broken (search endpoints and Site Search fail in production; not content-related).
Links
"track_scores": trueto sorted queries; does not cover built-in Site Search.Affected file:
dotCMS/src/main/java/com/dotcms/rest/elasticsearch/ESContentResourcePortlet.java