Solr range query for specefic id like /solr/select

2019-04-29 23:13发布

问题:

I have some specific id like 1,2,5,11,64589 in solr (int type)

I want to qet query like ttp://localhost:8983/solr/select?q=x:[1,2,5,11,64589] but does not work (get error). how can do it ???

Note: i can implement with "OR" but i want simple way (and other problem limit in max url char length)

回答1:

These are your options:

  • ?q=x:(1 OR 2 OR 5 OR ...)
  • ?q=x:1 OR x:2 OR x:5 OR ...
  • ?q=x:(1 2 5 ...) with defaultOperator="OR" (haven't tried this one but it should work)
  • Write your own RequestHandler
  • Write your own QueryParser


回答2:

In Solr 4.10 and Heliosearch 0.07, you can use the more efficient terms query:

q={!terms f=id}1,2,5,11,64589


标签: solr