Space in the confluence space title is not considered while searching using /rest/spacedirectory/1/search

We are searching for spaces based on user inputs using /rest/spacedirectory/1/search rest endpoint. But it seems it is having trouble with searching when there is space in the user inputs.

I have created 3 spaces with the title as ntr - advise, ntr - w and ntr - win. When I am trying to search using ntr, I am getting all the three spaces. But when I am trying to search ntr - w, I am only getting spaces ntr - advise and ntr - win. I have also used the encodeUriComponent method to encode the search term. But this does not help. Also used /rest/api/search with cql, getting the same results.

Please help me with how to get the proper spaces from the user inputs.