Search code examples
javaxodus

Filter getAll query results


This is how to limit the query of Entities using Xodus API:

final EntityIterable allUsers = txn.getAll(storeName).skip(skip).take(limit);

Question, say the entities stored in the database range from 100k to 500k records, is there a way to filter result based on specific Entity property?


Solution

  • You can create an EntityIterable with entities having a property equal to a specific value (Searching by Property Value). E.g., find users with specified login name (property "login"):

    final EntityIterable users = txn.find("User", "login", loginName);
    

    Also you can create an EntityIterable with entities having a property value in specified range (Searching in Range of Property Values). E.g., find users whose age is in the range of [17-23], inclusively:

    final EntityIterable students = txn.find("User", "age", 17, 23);