tags:

views:

214

answers:

1

I want to use a query like:

sql(select name where id > 10 and id < 100 )

by using Solr or in SolrJ, but do not know how to implement? Can someone explain?

+2  A: 

You need a range query, as described in SolrQuerySyntax. Basically, you collect all relevant documents by using a query range and then select the name field. The syntax is something like:

http://localhost:8983/solr/select?q=id:[10 TO 100]&fl=name

(You will need to escape the URL).

Yuval F
Thanks!For examples, My index have 3 field:title, x and y , and I want to query like: SQL(select title where x>10 and x < 100 and y > 20 and y < 300), how to do by using Solr range query?
You need to combine two range queries (for the x and the y) using AND default. See http://wiki.apache.org/solr/LocalParams as to how to do this. Also, if you want the ranges to be non-inclusive (e.g. x>10 instead of x>=10) you need to use a curly bracket { instead of a square one [
Yuval F