Skip to content

Commit b69a95a

Browse files
amplia escopo de onde obter issns
1 parent d2e97b2 commit b69a95a

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

etl/deduplicator/openalex.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def _try_openalex_by_isbn(self, primary: dict, max_candidates: int) -> list:
9797
return matches
9898

9999
def _try_openalex_by_title(self, primary: dict, max_candidates: int) -> list:
100-
if extract_doi(primary) or extract_isbns(primary):
100+
if extract_isbns(primary):
101101
return []
102102

103103
matches = []
@@ -251,8 +251,6 @@ def _search_openalex_by_isbn(
251251
{"terms": {"ids.eisbns.keyword": isbns}},
252252
{"terms": {"biblio.isbn.keyword": isbns}},
253253
{"terms": {"biblio.isbns.keyword": isbns}},
254-
{"terms": {"primary_location.source.issns.keyword": isbns}},
255-
{"terms": {"locations.source.issns.keyword": isbns}},
256254
],
257255
"minimum_should_match": 1,
258256
}
@@ -275,7 +273,7 @@ def _search_openalex_by_title_year(
275273
size: int = 10,
276274
) -> List[Dict[str, Any]]:
277275
title = scielo_doc.get("title", "")
278-
issns = scielo_doc.get("source_issns", [])
276+
issns = scielo_doc.get("source_issns") or []
279277
if not title:
280278
return []
281279

@@ -297,7 +295,7 @@ def _search_openalex_by_title_year(
297295
self._apply_openalex_query_constraints(query, scielo_doc)
298296

299297
if issns:
300-
query["bool"]["should"] = [{"terms": {"source.issns": issns}}]
298+
query["bool"]["should"] = self._source_issn_queries(issns)
301299
query["bool"]["minimum_should_match"] = 1
302300

303301
try:
@@ -310,6 +308,16 @@ def _search_openalex_by_title_year(
310308
logger.error("Error searching OpenAlex by title: %s", exc)
311309
return []
312310

311+
def _source_issn_queries(self, issns: list[str]) -> list[dict[str, Any]]:
312+
return [
313+
{"terms": {"source.issn.keyword": issns}},
314+
{"terms": {"source.issns.keyword": issns}},
315+
{"terms": {"primary_location.source.issn.keyword": issns}},
316+
{"terms": {"primary_location.source.issns.keyword": issns}},
317+
{"terms": {"locations.source.issn.keyword": issns}},
318+
{"terms": {"locations.source.issns.keyword": issns}},
319+
]
320+
313321
def _validate_openalex_match(
314322
self,
315323
scielo_doc: Dict[str, Any],

0 commit comments

Comments
 (0)