Announcement Announcement Module
Collapse
No announcement yet.
Spring Data Graph: Multiple index queries? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Data Graph: Multiple index queries?

    Given a situation where I have an Entity with multiple indexes.

    Code:
    public class User
    {
    	@Indexed(indexName = "user-firstname", fulltext=true) private String firstName;
    	@Indexed(indexName = "user-lastname", fulltext=true) private String lastName;
    }
    I know I can search for all users who's first name starts with Jeff by doing:

    userRepository.findAllByQuery("user-firstname", "firstName", "Jeff*");

    But what if I want to get all users who's first name starts with Jeff, and last name starts with "Anders*" or something like that?

  • #2
    You should probably use the same index name and then you can do

    findAllByQuery("firstName:Jeff* AND lastName:Anders*")

    HTH

    Michael

    Comment


    • #3
      Ok, took your hint,

      Reverted the User class to
      Code:
      public class User
      {
      	@Indexed private String firstName;
      	@Indexed private String lastName;
      }
      And the query is now

      Code:
      ClosableIterable<User> iterableUsers = userRepository.findAllByQuery("User", null, "firstName:Jeff* AND lastName:Anders*");
      This seems to work well enough.

      Comment

      Working...
      X