Nest .Sort() doesnt seem to except a list? Any work arounds?

Hello,

I am using ElasticSearch Nest Fluent DSL and cant seem to figure out how to create a list of Sorts that the .Sort() accepts.

I have an array of sorts and i want to convert them to work with Nest a bit like you can do with Filters:

new List<Func<QueryContainerDescriptor, QueryContainer>>();

Any ideas?

Thanks

Figured it out:

 Func<SortDescriptor<dynamic>, IPromise<IList<ISort>>> sortList = st =>
            {
                if (queryBuilder.Sort != null)
                {
                    foreach (var option in queryBuilder.Sort)
                    {    
                        if (option.SortOrder == "ASC")
                        {
                            st.Ascending(option.Key);
                        }
                        else
                        {
                            st.Descending(option.Key);
                        }
                    }
                }
                else
                {
                    st.Ascending(SortSpecialField.Score);
                }
                return st;
            };

Then in the query:

.Sort(sortList)

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.