def METHOD_NAME(
    self,
    identity,
    community_id,
    params=None,
    search_preference=None,
    extra_filter=None,
    **kwargs
):
    """Search for records published in the given community."""
    self.require_permission(identity, "search")
    community = self.community_cls.pid.resolve(
        community_id
    )  # Ensure community's existence
    params = params or {}
    community_filter = dsl.Q(
        "term", **{"parent.communities.ids": str(community.id)}
    )
    if extra_filter is not None:
        community_filter = community_filter & extra_filter
    METHOD_NAME = self._search(
        "search",
        identity,
        params,
        search_preference,
        extra_filter=community_filter,
        permission_action="read",
        **kwargs,
    )
    search_result = METHOD_NAME.execute()
    return self.result_list(
        self,
        identity,
        search_result,
        params,
        links_tpl=LinksTemplate(
            self.config.links_search_community_records,
            context={
                "args": params,
                "id": community_id,
            },
        ),
        links_item_tpl=self.links_item_tpl,
    )