1

As you know, in spring data JPA, we can use @Table(indexes) to create indexes:

@Entity
@Table(name = "a", indexes = {
        @Index(name = "name_idx", columnList = "name", unique = false) })
public class A {

    @Id
    @Column(name = "id")
    private Integer id;

    @Column(name = "name", length = 50)
    private String name;

    '''other columns and methods'''

}

But it seems that we can't specify the index type, so is there a solution that we specify one column to a FULLTEXT index?

1 Answer 1

3

Yes, I have found a workaround, you can use the columnDefinition parameter of the @Column annotation to add a FULLTEXT KEY. It's not a perfect solution, but i think it's okay as a workaround.

@Column(name = "url", columnDefinition = "VARCHAR(2048) NOT NULL, FULLTEXT KEY urlFulltext (url)")
private String url;

best regards

Thorben

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.