Examine sorting by string not working in Umbraco 1...
# help-with-umbraco
d
Hi all, We want to be able to sort the results based on a string field(aggregationTitleSortable). This is what we have done so far but it is not sorting the results alphabetically.
Copy code
public class ExamineComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
    {
        builder.Services.ConfigureOptions<ConfigureExternalIndexOptions>();
    }
}
Copy code
public class ConfigureExternalIndexOptions : IConfigureNamedOptions<LuceneDirectoryIndexOptions>
{
    public void Configure(string? name, LuceneDirectoryIndexOptions options)
    {
        options.FieldDefinitions.AddOrUpdate(new FieldDefinition("aggregationTitleSortable", FieldDefinitionTypes.FullTextSortable));
    }
}
Search Service
Copy code
public SearchResponseModel ServicePartnerSearch(SearchRequestModel searchRequest)      
 {
     IBooleanOperation? query = index.Searcher.CreateQuery(IndexTypes.Content).NodeTypeAlias("servicePartnerPage").And()
             .GroupedNot(new string[] { "umbracoNavHide" }, new string[] { "1" });

     if (searchRequest.SelectedPartnerTypeTags != null)
     {
         query.And().GroupedOr(new string[] { "partnerTypeCustom" }, searchRequest.SelectedPartnerTypeTags);
     }

     if (searchRequest.SelectedContinentTags != null)
     {
         query.And().GroupedOr(new string[] { "continentCustom" }, searchRequest.SelectedContinentTags);
     }

     query.OrderBy(new SortableField("aggregationTitleSortable", SortType.String));
     ISearchResults? pageOfResults = query.Execute(new QueryOptions(searchRequest.Skip, searchRequest.PageSize));

     return new SearchResponseModel(searchRequest.Query, pageOfResults.TotalItemCount, pageOfResults);
 }
I can see the value getting correctly set also.(screenshot attached) Can someone please point me if I am doing something wrong? https://cdn.discordapp.com/attachments/1273575629106970734/1273575629417087048/Examine_sort_issue.png?ex=66bf1d3b&is=66bdcbbb&hm=5a95c35f68d7d4db12654dc3591ecb82e4dd3500116873500b2ba267fa6d309c&
I have written a blog explaining the solution and it can be found here https://www.debasish.tech/blogs/how-to-sort-on-a-string-field-in-umbraco-examine
5 Views