Announcement Announcement Module
No announcement yet.
FullText index works sometimes but not others. Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • FullText index works sometimes but not others.

    So I have a User with a fullName property that has @Indexed IndexType.FULLTEXT.

    @Indexed(indexName = "fullName", indexType = IndexType.FULLTEXT)
    private String fullName;

    If I have names like

    Cathy Johnson
    John Doe
    Alex Lifeson
    Bill Hader
    and more.

    I have done some tests where if I type in "John*" or "John" I correctly get Cathy Johnson and John Doe. But if I use "Alex*" or "Alex" I get no results, if I type "Bill*" or "Bill" I get no results. So it looks like it works sometimes but not others.

    Here is the derived query method in my UserRepository interface

    Page<User> findByFullName(String fullName, Pageable pageable);

    Here is my code in my service calling that repo method

    List<User> results =
                    userRepository.findByFullName(searchCriteria + "*", PageRequestHandler.getPageRequest())
    I even modified it so it didn't concatenate the "*" but always the same results as above.



  • #2

    I'll investigate, non-determinism here sounds very wrong. Bit busy today though so might have to wait until after the weekend.



    • #3

      I have had no luck reproducing this, but I have a test for documentation:

      public class FullTextIndexTests {
          private TeamRepositoryExtension teams;
          public void shouldIndexProperly() throws Exception {
     Team("Los Angeles Lakers"));
     Team("Los Angeles Dodgers"));
     Team("Los Angeles Clippers"));
     Team("Boston Celtics"));
     Team("Los Angeles Kings"));
     Team("Brooklyn Dodgers"));
     Team("Los Angeles Galaxy"));
     Team("Charlotte Bobcats"));
              assertThat(find("Los"), is(equalTo(5)));
              assertThat(find("les"), is(equalTo(0)));
              assertThat(find("lOS"), is(equalTo(5)));
              assertThat(find("Dodgers"), is(equalTo(2)));
              assertThat(find("odgers"), is(equalTo(0)));
              assertThat(find("*odgers"), is(equalTo(2)));
              assertThat(find("*odg*"), is(equalTo(2)));
              assertThat(find("Dodger"), is(equalTo(0)));
              assertThat(find("Dodger?"), is(equalTo(2)));
              assertThat(find("Ang*"), is(equalTo(5)));
              assertThat(find("B*"), is(equalTo(3)));
          private int find(String name) {
              return teams.findByName(name, new PageRequest(0, 20)).getNumberOfElements();
      Entity and repo look thus:

      public class Team {
          private Long id;
          @Indexed(indexName = "somethingdifferent", indexType = IndexType.FULLTEXT)
          private String name;
          public Team() {
          public Team(String name) {
     = name;
      public interface TeamRepository extends GraphRepository<Team> {
      public interface TeamRepositoryExtension extends TeamRepository {
          Page<Team> findByName(String name, Pageable pageable);
      Lucene terms and wildcars are explained in more details here:

      Hope that helps - if you are able to reproduce the problem with a test I can take another look.




      • #4
        Thanks for looking into that Lasse. Your code looks exactly what I have. And your results are what I would expect to be.

        But all I can say at this point is it doesn't work on my machine.

        It is extremely difficult for me to just do a demo on that smaller portion of my entire app.