0

I have the following entity in a Spring Boot project:

@Entity
@Getter
@Setter
@Table(name = "listings",
        indexes = {
                @Index(name = "idx_exposition_east", columnList = "exposition_east", unique = false),
                @Index(name = "idx_exposition_north", columnList = "exposition_north", unique = false),
                @Index(name = "idx_exposition_west", columnList = "exposition_west", unique = false),
                @Index(name = "idx_exposition_south", columnList = "exposition_south", unique = false)
                // some other indexes
        },
        uniqueConstraints = @UniqueConstraint(columnNames = {"source_id", "source_remote_id"})
)
public class ListingEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(name = "source_id", columnDefinition = "TINYINT", nullable = false)
    private Byte sourceId;

    @Column(columnDefinition = "VARCHAR(11)")
    private String sourceRemoteId;
    
    // some other columns
    
    @Length(max = 20_000)
    @Column(columnDefinition = "NVARCHAR(MAX)")
    private String description;

}

Is there any way for me to mark the description filed with a full-text search index? I use Microsoft SQL Server.

1 Answer 1

0

Steps to follow full text search -

  1. You need a full-text catalog before creating the full-text index:
CREATE FULLTEXT CATALOG ListingsFullTextCatalog;
  1. Add Full-Text Index on the description Column
CREATE FULLTEXT INDEX ON listings(description)
KEY INDEX PK_listings  -- replace with your actual PK index name
ON ListingsFullTextCatalog
WITH CHANGE_TRACKING AUTO;

Note- Make sure the Full-Text Search feature is installed on your MSSQL Server instance.

To make this automate make use of flyway or liquidBase migration.

If you don't want to manually create index and are in search of in-app feature, use elasticSearch or Lucene for full text capability.

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.