Pre Sorted document ids



we are currently trying to get back Document Ids from the FTS in a pre-sorted order.
We are executing the search using DocIdSearchQuery and additional Queries from the php sdk.
The Ids passed to DocIdSearchQuery are pre-sorted and we would like to get the document Ids of matching documents back in the same order as passed to DocIdSearchQuery. Currently we are getting them back sorted by score.

I have searched in both documentation and forum and haven’t found anything to get this to work.

Is this possible?


Max K.


You can pass special value "-_id" as sort argument, and the results will be sorted by ID.

More info about FTS sorting here:


Thanks for the quick response @avsej
That would sort it by id descending or ascending.
The ids we pass in are sorted in a specific way, not descending or ascending.

Is it possible to maintain the order of the ids we passed in?


I don’t think so. Unless you will let the server aware of your custom sorting. For example, you could add some index field, and maintain it to use custom ordering.


Okay, I don’t think that’ll work for our use case since the order changes with each request, thank you though.


Maybe if you will give more details on how the order is generated, we can think of better solution?