diff --git a/service/src/main/inse/orgminer/logic.py b/service/src/main/inse/orgminer/logic.py index b93e910f..fea770b0 100644 --- a/service/src/main/inse/orgminer/logic.py +++ b/service/src/main/inse/orgminer/logic.py @@ -256,7 +256,7 @@ async def get_classified_pages_aggs(org_url: str,institution_id: str = DEFAULT_I buckets = response.get("aggregations", {}).get("categories", {}).get("buckets", []) return [CategoryBucket(category=bucket["key"], count=bucket["doc_count"]) for bucket in buckets] -async def get_classified_pages(org_url: str,institution_id: str = DEFAULT_INSTITUTION_ID,) -> list[ClassifiedPage]: +async def get_classified_pages(org_url: str,institution_id: str = DEFAULT_INSTITUTION_ID,category: str | None = None,page: int = 1,size: int = 10) -> list[ClassifiedPage]: """ Returns the classified pages of the orgminer org. """ @@ -277,7 +277,21 @@ async def get_classified_pages(org_url: str,institution_id: str = DEFAULT_INSTIT "minimum_should_match": 1 } } + if category: + query["bool"]["filter"] = [ + { + "term": { + "category.keyword": category + } + } + ] + body = { + "query": query, + "from": (page - 1) * size, + "size": size, + + } index = resolve_urls_categorized_es_index(institution_id) - response = await search(query=query,index=index,cluster=ESCluster.INSE) + response = await search(body=body,index=index,cluster=ESCluster.INSE) classified_pages = [ClassifiedPage.from_es_hit(hit) for hit in response["hits"]["hits"]] return classified_pages \ No newline at end of file diff --git a/service/src/main/inse/orgminer/service.py b/service/src/main/inse/orgminer/service.py index 4f78a956..f047d045 100644 --- a/service/src/main/inse/orgminer/service.py +++ b/service/src/main/inse/orgminer/service.py @@ -124,4 +124,4 @@ async def get_classified_pages( institution_id = _get_account_institution_id(session, access_token_metadata.effective_account_id) if not institution_id: institution_id = DEFAULT_INSTITUTION_ID - return await logic.get_classified_pages(org_url,full_institution_url(institution_id)) \ No newline at end of file + return await logic.get_classified_pages(org_url=org_url,institution_id=full_institution_url(institution_id),category=category,page=page,size=size) \ No newline at end of file