Hibernate Search working on one environment but not the others

skyblue Source

this is my first hibernate search attempt so i'm new to this. I had an entity that i made it indexed so i can search the name field. it is working on my machine by at my teammates whenever they search for anything it returns 0 results although there are other hibernate search parts that are working fine at their end

the query i used looks like this

public List<Agency> findByText(String text) {
        FullTextEntityManager ftManager = org.hibernate.search.jpa.Search.getFullTextEntityManager(entityManager);
    try {
        return ftManager
                .createFullTextQuery(
                        new MultiFieldQueryParser(new String[] { "name" }, new StandardAnalyzer()).parse(text
                                + "*"), Agency.class).getResultList();
    } catch (ParseException e) {
        log.error("Exception has occurred when trying to execute search", e);
    }

    return Collections.emptyList();
}

agency entity

@Entity
@Indexed
@Table(
        name="Agency",
        uniqueConstraints=
            @UniqueConstraint(columnNames={"id", "name"})
    )
public class Agency {

    @Id
    @GeneratedValue
    private Long id;

    @Field(index = Index.TOKENIZED, store = Store.NO)
    private String name;
hibernatehibernate-search

Answers

answered 7 years ago Alex Barnes #1

I recommend that you examine the Lucene indexes using Luke. This will allow you to see what is indexed and therefore what you can expect to be returned.

It might be that you've not got your transactions set up quite right and that database changes are not being reflected in your indexes.

Also, if you're new to Hibernate search it's interesting and enlightening to see what the indexes actually contain.

comments powered by Disqus