jay
jay

Reputation: 2077

solr query without order

I have a solr index with the unique field as "id".

I have a ordered set of ids, using which I would like to query Solr. But I want the results in the same order.

so for example if i have the ids id = [5,1,3,4] I want the results displayed in solr in same order.

I tried http://localhost:8983/solr/select/?q=id:(5 OR 1 OR 3 OR 4)&fl=id, but the results displayed are in ascending order.

Is their a way to query solr, and get results as I mentioned?

Upvotes: 1

Views: 956

Answers (3)

Tim Liu
Tim Liu

Reputation: 16

The simple way is to query solr and sort the results in codes of yourself.

Upvotes: 0

bxfckrclooo
bxfckrclooo

Reputation: 598

You can add another field to keep the initial sort order. You then can sort=field asc to retrieve the data in the original order.

Upvotes: 0

Umer
Umer

Reputation: 1921

I think you can't, The results appear in the order they are indexed unless you specify a default sort field or the explicit sort field/order.

Upvotes: 1

Related Questions