EthanHu
EthanHu

Reputation: 87

Question about Solr and SolrJ range query?

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]

Upvotes: 1

Views: 2717

Answers (2)

Illu
Illu

Reputation: 65

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

Upvotes: 1

joeslice
joeslice

Reputation: 3454

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

Upvotes: 2

Related Questions