Skip to content

Commit 2f60407

Browse files
authored
Merge pull request #156 from SynBioDex/153-use-minhash-for-similar-and-hash-for-exact-sequence-clustering
skip the part with long id
2 parents 0bd9f12 + b2f097a commit 2f60407

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

flask/index.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,17 @@ def index_page(es, parts_page, index_name, uri2rank, term_list):
130130
add_roles(parts_page, term_list)
131131
add_sbol_type(parts_page)
132132

133+
skipped = []
134+
133135
def actions():
134136
for part in parts_page:
137+
# ES rejects the whole bulk request if any _id exceeds 512 bytes,
138+
# which would kill the entire page. Skip the (rare) parts with a
139+
# pathologically long subject URI; they're logged below, not
140+
# silently dropped.
141+
if len(part['subject'].encode('utf-8')) > 512:
142+
skipped.append(part['subject'])
143+
continue
135144
yield {
136145
'_index': index_name,
137146
'_type': index_name,
@@ -144,6 +153,9 @@ def actions():
144153
except Exception as e:
145154
logger_.log(f'[ERROR] Error during bulk indexing: {str(e)}', True)
146155
raise
156+
if skipped:
157+
logger_.log(f'[WARN] skipped {len(skipped)} part(s) with subject URI > 512 bytes '
158+
f'(ES _id limit); first: {skipped[0][:120]}', True)
147159

148160

149161
def update_index(uri2rank):

0 commit comments

Comments
 (0)