jnosql icon indicating copy to clipboard operation
jnosql copied to clipboard

Support for automatic creation of indexes

Open adam-waldenberg opened this issue 6 years ago • 0 comments

It would be great if there was support for the automatic creation of indexes. In JPA there is an @Index annotation that does the same thing.

It would be useful to be able to create indexes directly on top of properties in an entity, like so -

@Data
@Entity("accounts")
public class Account implements Serializable {
	private @Column @Id ObjectId id;
	private @Column @NotEmpty @Index String firstName;
	private @Column @NotEmpty String lastName;
}

While this works fine for very simple indexes where you only do simple lookups on a specific propetrty such as firstName - queries are often more complicated - so support for compound indexes would also be needed;

@Data
@Entity("accounts", compoundIndexes = { @CompoundIndex(columnNames = {"firstName", "lastName"}) })
public class Account implements Serializable {
	private @Column @Id ObjectId id;
	private @Column @NotEmpty @Index String firstName;
	private @Column @NotEmpty String lastName;
}

adam-waldenberg avatar Mar 07 '19 12:03 adam-waldenberg