Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate Search @IndexedEmbedded

I have a similar situation like 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;
    ...
}

The problem now is the following: If I change for example the name field in entity Place which entities are going to be re-indexed?

1) Only the name field?

2) The whole Place entity?

3) The whole Place entity and the entities annotated with @IndexedEmbedded?

The one I need for my purpose would be the third. So if it is not standard, could there be any solution to achieve this behaviour?

like image 948
Hons Avatar asked Oct 11 '22 00:10

Hons


1 Answers

Fortunately it's really the third, so I was lucky and it works as expected

like image 170
Hons Avatar answered Oct 14 '22 05:10

Hons