inor
inor

Reputation: 2846

How to search in Spring Solr for multiple values

I'm using Java, Spring, solr... trying to construct a query that among other things could find all entities where a String field "myField" is either "abc def" or "hij klm"

With code that does the following:

String value;
...
query.addCriteria(new Criteria("myField").expression(value));

I've tried all of the following and it always fails:

String value = "abc def OR hij klm";
String value = "abc\ def OR hij\ klm";
String value = "\"abc def\" OR \"hij klm\"";
String value = "\"abc\ def\" OR \"hij\ klm\"";

What value should I pass in order to match this?

Upvotes: 0

Views: 539

Answers (1)

inor
inor

Reputation: 2846

Finally this seems to do the job:

query.addCriteria( new Criteria(fieldName).in(new Object[]{"abc def","hij klm"}));   

Upvotes: 2

Related Questions