DemonicTutor opened a new issue, #10515:
URL: https://github.com/apache/ignite/issues/10515
the order of the indexed fields defines the order how the clauses apply and
it looks like that only if all clauses from the start are `IN` clauses they
work as expected.
once a different clause (eg `EQ`) is evaluated following `IN` clauses do no
longer apply.
For example if combining `GTE` with `IN` and a second `IN` the second `IN`
clause gets ignored:
```
>>> orgId >= 0, role[a,b], other[x]
>>> Entry [key=PersonKey{id=1, orgId=1}, val=Person{role='a', other='x',
salary=1}]
>>> Entry [key=PersonKey{id=5, orgId=1}, val=Person{role='a', other='x',
salary=2}]
>>> Entry [key=PersonKey{id=2, orgId=1}, val=Person{role='a', other='y',
salary=1}]
>>> Entry [key=PersonKey{id=6, orgId=1}, val=Person{role='a', other='y',
salary=2}]
>>> Entry [key=PersonKey{id=4, orgId=1}, val=Person{role='b', other='x',
salary=1}]
>>> Entry [key=PersonKey{id=8, orgId=1}, val=Person{role='b', other='x',
salary=2}]
>>> Entry [key=PersonKey{id=3, orgId=1}, val=Person{role='b', other='y',
salary=1}]
>>> Entry [key=PersonKey{id=7, orgId=1}, val=Person{role='b', other='y',
salary=2}]
>>> Entry [key=PersonKey{id=9, orgId=2}, val=Person{role='a', other='x',
salary=1}]
>>> Entry [key=PersonKey{id=13, orgId=2}, val=Person{role='a',
other='x', salary=2}]
>>> Entry [key=PersonKey{id=10, orgId=2}, val=Person{role='a',
other='y', salary=1}]
>>> Entry [key=PersonKey{id=14, orgId=2}, val=Person{role='a',
other='y', salary=2}]
>>> Entry [key=PersonKey{id=12, orgId=2}, val=Person{role='b',
other='x', salary=1}]
>>> Entry [key=PersonKey{id=16, orgId=2}, val=Person{role='b',
other='x', salary=2}]
>>> Entry [key=PersonKey{id=11, orgId=2}, val=Person{role='b',
other='y', salary=1}]
>>> Entry [key=PersonKey{id=15, orgId=2}, val=Person{role='b',
other='y', salary=2}]
```
I used CacheQueryExample to show the issue im facing:
https://github.com/DemonicTutor/ignite/blob/a3d4cf14d41bbc869950f4a21aed73f276794d5e/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
My UseCase / What i tried to achive: Basically a Specification-Pattern
search over an Entity (8 properties i want to be indexed/searchable) with a
CompositeKey (3 properties) of which i require one to define the **SortOrder**
```
MyKey {
long: id; <<== Affinity and sort order for results therefore also indexed
"my_idx"
String id2;
String id3;
}
MyValue {
private String first; <<- indexed "my_idx"
private String second; <<-- indexed "my_idx"
private boolean third; <<-- indexed "my_idx"
}
public Observable<JsonObject> search(final Criteria criteria, final int
limit, final int skip) {
// Iterator returning search result ordered by MyKey.id to enable
"limit" and "skip" consistently
final var result = outcomes.query(criteria.query()))
....
}
IndexQuery<OutcomeKey, Outcome> query() {
final var criteria = new ArrayList<IndexQueryCriterion>(8);
if (!optionalFirstContains.isEmpty()) {
criteria.add(IndexQueryCriteriaBuilder.in("first",
optionalFirstContains));
}
if (!optionalSecondContains.isEmpty()) {
criteria.add(IndexQueryCriteriaBuilder.in("second",
optionalSecondContains));
}
criteria.add(IndexQueryCriteriaBuilder.gt("id", -1)) // artificially
added because ignite's index implementation demands it
return new IndexQuery<OutcomeKey,
Outcome>(Outcome.class).setCriteria(criteria);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]