From 912023aa8cd338890abe125adfaaf407ff6b1613 Mon Sep 17 00:00:00 2001 From: genja Date: Tue, 14 Jul 2026 19:51:55 +0200 Subject: [PATCH] applied new patents matching (EU to EPO/USPTO) --- service/src/main/inse/patents/all/logic.py | 23 ++++------- service/src/main/inse/patents/all/service.py | 2 - .../elastic_search_all_patents_client.py | 40 +++++++++---------- .../patent-detail/patent-detail.component.ts | 13 ++---- 4 files changed, 29 insertions(+), 49 deletions(-) diff --git a/service/src/main/inse/patents/all/logic.py b/service/src/main/inse/patents/all/logic.py index 76defc74..2abb9c43 100644 --- a/service/src/main/inse/patents/all/logic.py +++ b/service/src/main/inse/patents/all/logic.py @@ -118,7 +118,7 @@ def _parse_patent_id(patent_id: str) -> tuple[str, str]: async def _search_by_id( client: AllPatentsSearchClient, patent_id: str, - filling_date: str | None = None, + title: str | None = None, ) -> list[model.PatentEntry]: try: source, number = _parse_patent_id(patent_id) @@ -126,28 +126,27 @@ async def _search_by_id( return [] if source == "EPO": - data = await client.search_epo(client.epo_detail_query(number, filling_date)) + data = await client.search_epo(client.epo_detail_query(number, title)) return parse_epo_hits(data) - data = await client.search_uspto(client.uspto_detail_query(number, filling_date)) + data = await client.search_uspto(client.uspto_detail_query(number)) return parse_uspto_hits(data) async def _search_by_title( client: AllPatentsSearchClient, title: str, - filling_date: str | None = None, prefix: str | None = None, ) -> list[model.PatentEntry]: if prefix and prefix.upper() == "US": - data = await client.search_uspto(client.uspto_title_query(title, filling_date)) + data = await client.search_uspto(client.uspto_title_query(title)) return parse_uspto_hits(data) if prefix and prefix.upper() == "EP": - data = await client.search_epo(client.epo_title_query(title, filling_date)) + data = await client.search_epo(client.epo_title_query(title)) return parse_epo_hits(data) epo_data, uspto_data = await asyncio.gather( - client.search_epo(client.epo_title_query(title, filling_date)), - client.search_uspto(client.uspto_title_query(title, filling_date)), + client.search_epo(client.epo_title_query(title)), + client.search_uspto(client.uspto_title_query(title)), ) return parse_epo_hits(epo_data) + parse_uspto_hits(uspto_data) @@ -156,29 +155,23 @@ async def get_patent_by_id( patent_id: str, prefix: str | None = None, title: str | None = None, - filling_date: str | None = None, ipc_client: IpcSearchClient | None = None, ) -> model.PatentEntry: all_patents_client = AllPatentsSearchClient() ipc_search_client = ipc_client or IpcSearchClient() - normalized_filling_date = ( - _normalize_patent_date(filling_date) if filling_date else None - ) - lookup_id = patent_id if prefix and not patent_id.upper().startswith(prefix.upper()): lookup_id = f"{prefix.upper()}{patent_id}" try: patents = await _search_by_id( - all_patents_client, lookup_id, normalized_filling_date + all_patents_client, lookup_id, ) if not patents and title: patents = await _search_by_title( all_patents_client, title, - normalized_filling_date, prefix, ) diff --git a/service/src/main/inse/patents/all/service.py b/service/src/main/inse/patents/all/service.py index 2126fc29..e0aaffc2 100644 --- a/service/src/main/inse/patents/all/service.py +++ b/service/src/main/inse/patents/all/service.py @@ -45,11 +45,9 @@ async def get_patent_by_identifier( identifier: str, prefix: str | None = None, title: str | None = None, - filling_date: str | None = None, ): return await logic.get_patent_by_id( patent_id=identifier, prefix=prefix, title=title, - filling_date=filling_date, ) diff --git a/service/src/main/inse/patents/elastic_search_all_patents_client.py b/service/src/main/inse/patents/elastic_search_all_patents_client.py index f7b33cc1..faf29ded 100644 --- a/service/src/main/inse/patents/elastic_search_all_patents_client.py +++ b/service/src/main/inse/patents/elastic_search_all_patents_client.py @@ -152,21 +152,28 @@ class AllPatentsSearchClient: "query": query, } - def epo_detail_query(self, doc_number: str,filling_date: str | None = None) -> dict[str, Any]: + def epo_detail_query(self, doc_number: str, title: str | None = None) -> dict[str, Any]: query: dict[str, Any] = { "bool": { "should": [ + {"wildcard": { #eu cordis patents compatibility + "application_number": { + "value": f"{doc_number}*" + } + } + }, {"term": {"doc_number": doc_number}}, - {"term": {"doc_number": self.remove_year(doc_number)}}, - {"term": {"application_number": self.remove_year(doc_number)}}, - {"term": {"application_number": doc_number}}, ], "minimum_should_match": 1, } } - if filling_date: - query["bool"]["must"] = [{"term": {"application_filing_date": filling_date}}] - + if title: #eu cordis patents compatibility + query["bool"]["should"].append( + {"match": {"title_en": title}} + ) + query["bool"]["should"].append( + {"match": {"title_de": title}} + ) return { "size": 1, "_source": [ @@ -178,21 +185,16 @@ class AllPatentsSearchClient: "query": query, } - def uspto_detail_query(self, number: str,filling_date: str | None = None) -> dict[str, Any]: + def uspto_detail_query(self, number: str) -> dict[str, Any]: query: dict[str, Any] = { "bool": { "should": [ {"term": {"publication_number": number}}, - {"term": {"publication_number": self.remove_year(number)}}, - {"term": {"application_number": number}}, - {"term": {"application_number": self.remove_year(number)}}, + {"term": {"application_number": self.remove_year(number)}}, #eu cordis patents compatibility ], "minimum_should_match": 1, } } - if filling_date: - query["bool"]["must"] = [{"term": {"application_date": filling_date}}] - return { "size": 1, "_source": [ @@ -204,7 +206,7 @@ class AllPatentsSearchClient: "query": query, } - def epo_title_query(self, title: str,filling_date: str | None = None) -> dict[str, Any]: + def epo_title_query(self, title: str) -> dict[str, Any]: query: dict[str, Any] = { "bool": { "should": [ @@ -214,9 +216,6 @@ class AllPatentsSearchClient: "minimum_should_match": 1, } } - if filling_date: - query["bool"]["must"] = [{"term": {"application_filing_date": filling_date}}] - return { "size": 1, "_source": [ @@ -228,16 +227,13 @@ class AllPatentsSearchClient: "query": query, } - def uspto_title_query(self, title: str,filling_date: str | None = None) -> dict[str, Any]: + def uspto_title_query(self, title: str) -> dict[str, Any]: query: dict[str, Any] = { "bool": { "should": [{"match_phrase": {"title": title}}], "minimum_should_match": 1, } } - if filling_date: - query["bool"]["must"] = [{"term": {"application_date": filling_date}}] - return { "size": 1, "_source": [ diff --git a/webapp/src/app/modules/patent-detail/patent-detail.component.ts b/webapp/src/app/modules/patent-detail/patent-detail.component.ts index 013f39a4..08af8d7d 100644 --- a/webapp/src/app/modules/patent-detail/patent-detail.component.ts +++ b/webapp/src/app/modules/patent-detail/patent-detail.component.ts @@ -63,10 +63,8 @@ export class PatentDetailComponent implements OnInit { this.route.snapshot.queryParamMap.get('title') ?? undefined; const prefix = this.route.snapshot.queryParamMap.get('prefix') ?? undefined; - const fillingDate = - this.route.snapshot.queryParamMap.get('fillingDate') ?? undefined; - this.loadPatent(patentId, title, prefix, fillingDate); + this.loadPatent(patentId, title, prefix); }); } @@ -130,19 +128,14 @@ export class PatentDetailComponent implements OnInit { return getDescriptionPreview(text); } - private loadPatent( - patentId: string, - title?: string, - prefix?: string, - fillingDate?: string, - ): void { + private loadPatent(patentId: string, title?: string, prefix?: string): void { this.loading = true; this.notFound = false; this.patent = null; this.expandedClassificationKeys.clear(); this.patentsService - .getPatentByIdOrTitle(patentId, prefix, title, fillingDate) + .getPatentByIdOrTitle(patentId, prefix, title) .pipe(finalize(() => (this.loading = false))) .subscribe({ next: (patent: PatentEntry) => {