开发者

Hibernate Search working on one environment but not the others

开发者 https://www.devze.com 2023-03-15 03:23 出处:网络
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 searc

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;


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消