ElasticSearch JAVA create custom sort in place of attribute value sort

For example, I have 6 accounts (1,2,34,5,6)of transactions in index and I want to search transactions and sort by order by account 4,6,3,2,1,5(custom order ) then how I can use it .

SearchResponse<MyClass> esResponse = esClient.search((s -> s
                 .index("loans")
                 .size(pageSize)
                 .from(page)
                 .query(q -> q
                     .terms(t -> t
                         .field("ic_number.keyword")
                         .terms(tqf -> tqf.value(/* List<String> here */))
                     )
                 ).sort(so -> so
                     .field(FieldSort.of(f -> f
                         .field("date_created")
                         .order(SortOrder.Desc)
                     ))
                 )
             ), MyClass.class);

How is that sort order defined? That is, how do you know that 6 comes between 4 and 3?

Your options are probably going to come down to

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