У меня есть сущность в JHipster (Inventory), которая содержит другую сущность (InventoryModel). Обе сущности настроены на свои собственные соответствующие индексы в верхней части каждого класса, однако я хочу, чтобы поле встроенной сущности было доступно для поиска в родительской сущности.
например. Я хочу, чтобы можно было выполнять поиск по индексу инвентаря для встроенного инвентаря.inventoryModel.name
/**
* A InventoryModel.
*/
@Entity
@Table(name = "inventory_model")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@org.springframework.data.elasticsearch.annotations.Document(indexName = "inventorymodel")
public class InventoryModel implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@org.springframework.data.elasticsearch.annotations.Field(type = FieldType.Keyword)
private Long id;
@NotNull
@Size(max = 20)
@Column(name = "name", length = 20, nullable = false, unique = true)
private String name;
@Enumerated(EnumType.STRING)
@Column(name = "vehicle_type")
private VehicleType vehicleType;
@Column(name = "jhi_desc")
private String desc;
@ManyToOne(optional = false)
@NotNull
@JsonIgnoreProperties("inventoryModels")
private Make make;
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
///
}
и
/**
* A Inventory.
*/
@Entity
@Table(name = "inventory")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@org.springframework.data.elasticsearch.annotations.Document(indexName = "inventory")
public class Inventory implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@org.springframework.data.elasticsearch.annotations.Field(type = FieldType.Keyword)
private Long id;
@NotNull
@Size(max = 17)
@Column(name = "vin", length = 17, nullable = false, unique = true)
private String vin;
@Min(value = 1900)
@Max(value = 2050)
@Column(name = "year")
private Integer year;
@Column(name = "color")
private String color;
@Size(max = 128)
@Column(name = "comment", length = 128)
private String comment;
@ManyToOne(optional = false)
@NotNull
@JsonIgnoreProperties("inventories")
@org.springframework.data.elasticsearch.annotations.Field(type = FieldType.Nested, includeInParent=true, index=true)
private InventoryModel inventoryModel;
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
///
}
в inventoryModel.name вы заметите аннотацию поля:
@ManyToOne(optional = false)
@NotNull
@JsonIgnoreProperties("inventories")
@org.springframework.data.elasticsearch.annotations.Field(type = FieldType.Nested, includeInParent=true, index=true)
private InventoryModel inventoryModel;
Однако, похоже, это никогда не работает, есть идеи?