We are using Azure Search to find items by path. We apply the following search code:
var filterPredicate = PredicateBuilder.True<SearchResultItem>(); filterPredicate.And(x => x.Path.StartsWith(rootItem.Paths.Path)); var query = context.GetQueryable<SearchResultItem>().Filter(filterPredicate); SearchResults<SearchResultItem> results = query.GetResults();
However, when we do this with a path that includes spaces, the query gets generated as the below query (taken from the logs):
10216 15:53:13 INFO AzureSearch Query [sitecore_master_index]: &search=(fullpath_1:(/\/sitecore\/content\/Sites\/Site.*/ /1\/Services\/ServiceA.*/))&queryType=full&$skip=0&$top=3&$count=true
Notice the extra
.* included after the
Site 1. This means that when the query gets executed, it returns all results whose path starts with
/sitecore/content/Sites/Site instead of only the results below the complete path.
Does anyone know how to resolve this issue?
- Sitecore 9.0.2
- Azure PaaS