Spring Data Solr Precedence for Custom Repository

I need to implement the following in a Spring Data Solr custom repository:

(X OR Y) AND Z

My current code is as follows:

Criteria criteria = new Criteria("x").is(X_VALUE);
criteria = criteria.or(new Criteria("y").is(Y_VALUE);
criteria = criteria.and(new Criteria("z").is(Z_VALUE);

But running this code I get the following precedence:

X OR (Y AND Z)

Any ideas?

Answers


The current API does not allow this combination of criteria. There's a patch attached to DATASOLR-105 which could help though it does not solve the problem fully.

Usage of SimpleStringCriteria might help for now. Please be aware of the fact, that values have to be converted to a Solr readable format.

new SimpleQuery(new SimpleStringCriteria("(x or y) and z"));

Update

Version 1.2 will have this issue fixed, so that its possible to create the query as follows.

Criteria orPart = Criteria.where("x").is("foo").or("y").is("bar");
Criteria andPart = Criteria.where("z").is("roo");
Query query = new SimpleQuery(orPart.and(andPart));

Need Your Help

How to handle concurrent file access with a filestream/streamwriter?

vb.net concurrency .net-2.0 filestream streamwriter

I am writing an audit file that is writing the username, time, and the old/changed values of several variables in the application for each user when they use my application. It is using a FileStre...

C++ Nested Loop dynamic array size

visual-studio c++-cli clr

I'm trying create a method that returns the sum of all values in an array list. I'm getting an error on this line sum+= setItem[x][y][z]; The error is