2011-09-14 6 views
4

내가 문제는 이제 다음과 같다 this one최대 절전 모드 검색

@Entity 
@Indexed 
public class Place { 
    @Id 
    @GeneratedValue 
    @DocumentId 
    private Long id; 

    @Field(index = Index.TOKENIZED) 
    private String name; 

    @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.REMOVE }) 
    @IndexedEmbedded 
    private Address address; 
    .... 
} 

@Entity 
public class Address { 
    @Id 
    @GeneratedValue 
    private Long id; 

    @Field(index=Index.TOKENIZED) 
    private String street; 

    @Field(index=Index.TOKENIZED) 
    private String city; 

    @ContainedIn 
    @OneToMany(mappedBy="address") 
    private Set<Place> places; 
    ... 
} 

같은 비슷한 상황이 @IndexedEmbedded : 나는 엔티티 장소에 예를 들어 이름 필드를 변경하는 경우 하는 엔티티로 가고있다 다시 색인이 생성 되었습니까?

1) 이름 만 필드?

2) 전체 장소 엔티티?

3) 주석 전체 장소 엔티티와 엔티티을 @IndexedEmbedded?

내 목적에 필요한 것은 세 번째 것입니다. 표준이 아닌 경우이 문제를 해결할 수있는 솔루션이 있습니까?

답변

4

다행히도 그것은 실제로 세 번째입니다. 그래서 저는 운이 좋았고 예상대로 작동했습니다.

0

당신은 장소 엔티티 수동

public void updateIndex(T entity){ 
     FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(em); 
     fullTextEntityManager.index(entity); 
     fullTextEntityManager.getSearchFactory().optimize(entity.getClass()); 
    } 

색인을 다시 다음과 같은 코드를 사용할 수 있습니다 둘째 당신이 자동으로 변경하는 개체의 인덱스를 업데이트 할 persistence.xml에서 루씬을 구성 할 수 있습니다 최대 절전 모드 사용하는 경우

+0

사실 내가 찾는 것은 아닙니다. 나는 자동 프로세스에 관심이있다 – Hons

+0

이 구성의 예제를 줄 수 있습니까? – alexander