1
votes

Suppose that my index has 3 fields: title, x and y.

I know one range(10 < x < 100) can query like this:

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

If I want to two range(10 < x <100 AND 20 < y < 300) query like

SQL(select title where x>10 and x < 100 and y > 20 and y < 300)

by using Solr range query or SolrJ, but I don't know how to implement this. Does anybody else know? Thanks

Email: [email protected]

2
Why is this community wiki? Does not look like a discussion kind of thing - Yuval F

2 Answers

2
votes

Take a look at the docs for SolrJ. Successive calls to addFilterQuery will continue to build up your query. Alternatively you can have two things in one fq:

http://localhost:8983/solr/select?q=&fq=x:[10+TO+100]+AND+y:[20+TO+300]&fl=title
1
votes

There is a method in class SolrQuery can solve your problem, setFilterQueries(String... fq) You can take a look at this.