@@ -626,9 +626,6 @@ async def delete(self, query: str) -> Response:
626626class DefaultSolrClient (SolrClient ):
627627 """Default implementation of the solr client."""
628628
629- delegate : AsyncClient
630- config : SolrClientConfig
631-
632629 def __init__ (self , cfg : SolrClientConfig ):
633630 self .config = cfg
634631 url_parsed = list (urlparse (cfg .base_url ))
@@ -758,23 +755,22 @@ async def create(self, core_name: str | None) -> None:
758755 """Create a core."""
759756 ...
760757
758+ @abstractmethod
759+ async def reload (self , core_name : str | None ) -> Response :
760+ """Reload a core."""
761+ ...
762+
761763
762764class DefaultSolrAdminClient (SolrAdminClient ):
763765 """A client to the core admin api.
764766
765767 Url: https://solr.apache.org/guide/solr/latest/configuration-guide/coreadmin-api.html
766768 """
767769
768- delegate : AsyncClient
769- config : SolrClientConfig
770-
771770 def __init__ (self , cfg : SolrClientConfig ):
772771 self .config = cfg
773- url_parsed = list (urlparse (cfg .base_url ))
774- url_parsed [2 ] = urljoin (url_parsed [2 ], "/api/cores" )
775- burl = urlunparse (url_parsed )
776772 bauth = BasicAuth (username = cfg .user .username , password = cfg .user .password ) if cfg .user is not None else None
777- self .delegate = AsyncClient (auth = bauth , base_url = burl , timeout = cfg .timeout )
773+ self .delegate = AsyncClient (auth = bauth , base_url = self . config . base_url , timeout = cfg .timeout )
778774
779775 async def __aenter__ (self ) -> Self :
780776 await self .delegate .__aenter__ ()
@@ -788,7 +784,7 @@ async def __aexit__(
788784 async def core_status (self , core_name : str | None ) -> dict [str , Any ] | None :
789785 """Return the status of the connected core or the one given by `core_name`."""
790786 core = core_name or self .config .core
791- resp = await self .delegate .get (f"/{ core } " )
787+ resp = await self .delegate .get (f"/api/cores/ { core } " )
792788 if not resp .is_success :
793789 raise SolrClientStatusException (self .config , resp )
794790 else :
@@ -800,8 +796,16 @@ async def create(self, core_name: str | None) -> None:
800796 """Create a core with the given `core_name` or the name provided in the config object."""
801797 core = core_name or self .config .core
802798 data = {"create" : {"name" : core , "configSet" : self .config .configset }}
803- resp = await self .delegate .post ("" , json = data )
799+ resp = await self .delegate .post ("/api/cores " , json = data )
804800 if not resp .is_success :
805801 raise SolrClientCreateCoreException (core , resp )
806802 else :
807803 return None
804+
805+ async def reload (self , core_name : str | None ) -> Response :
806+ """Reload a core with the given `core_name` or the name provided in the config object."""
807+ core = core_name or self .config .core
808+ return await self .delegate .post (
809+ f"/v2/cores/{ core } /reload" ,
810+ headers = {"Content-Type" : "application/json" },
811+ )
0 commit comments