solrspring-data-solr

How to write a Solr query to get all the documents by ids


I want to write a query that returns the documents with ids. For example, I want documents with ids 1-10. I want to write a query that will enable me doing that. Like q=id:1,q=2..... How?


Solution

  • You can do it in multiple ways:

    q=id:(1 2 3 4 5 6 7 8 9 10)
    

    or

    q=id:1 OR id:2 OR id:3 OR id:4 OR id:5 ..
    

    or

    q=id:[1 TO 10]
    

    or with q.op=OR:

    q=id:1 id:2 id:3 id:4 id:5 ..