Examine sorting by string not working in Umbraco 1...
# help-with-other
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/1272449772145344522/1272449772388749423/Examine_sort_issue.png?ex=66bb04b2&is=66b9b332&hm=16df3d0bd662183ca069a363f21fbd29d9ee087b73f5e5d2be6ce1b61fc87ad4&
Hi all, needed your inputs on this. Has anyone been able to sort based on a string in umbraco 10?
Hi all, I need your help on this. Can someone please help me with this?
j
Hey @Debasish, not everyone looks in here, it might be an idea to repost in #1125392773038755890
h
I've had a look at this and it seems it doesn't work in 13 either, so either a bug in Umbraco or Examine I guess
d
Hi @Jason I will repost this under help-with-umbraco. Thanks
6 Views