Skip to content

Commit 04e588b

Browse files
committed
fix: cap length for iri_values doc id
elasticsearch document ids may only be 512 bytes long, but the id used for trovesearch_denorm's iri_values index uses a base64-encoded url that may be longer -- use a hash instead
1 parent 3080226 commit 04e588b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

share/search/index_strategy/trovesearch_denorm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from collections import abc, defaultdict
33
import dataclasses
44
import functools
5+
import hashlib
56
import itertools
67
import json
78
import logging
@@ -374,7 +375,7 @@ def _doc_id(self, value_iri=None) -> str:
374375
return (
375376
_card_pk
376377
if value_iri is None
377-
else f'{_card_pk}-{ts.b64(value_iri)}'
378+
else f'{_card_pk}-{hashlib.sha256(value_iri.encode()).hexdigest()}'
378379
)
379380

380381
@functools.cached_property

0 commit comments

Comments
 (0)