I have the following annotation based elastic search configuration, I've set the index not to be analyzed because I don't want these fields to be tokenized:
@Document(indexName = "abc", type = "efg")
public class ResourceElasticSearch {
@Id
private String id;
@Field(type = FieldType.String, index = FieldIndex.not_analyzed)
private String name;
@Field(type = FieldType.String, store = true)
private List<String> tags = new ArrayList<>();
@Field(type = FieldType.String)
private String clientId;
@Field(type = FieldType.String, index = FieldIndex.not_analyzed)
private String virtualPath;
@Field(type = FieldType.Date)
private Date lastModifiedTime;
@Field(type = FieldType.Date)
private Date lastQueryTime;
@Field(type = FieldType.String)
private String modificationId;
@Field(type = FieldType.String)
private String realPath;
@Field(type = FieldType.String)
private String extension;
@Field(type = FieldType.String)
private ResourceType type;
Is it possible by using annotations to make the searches on the name, virtualPath and tags to be case-insensitive? The search looks like this, search by wildcard is required:
private QueryBuilder getQueryBuilderForSearch(SearchCriteria criteria) {
String virtualPath = criteria.getPath();
return boolQuery()
.must(wildcardQuery("virtualPath", virtualPath))
.must(wildcardQuery("name", criteria.getName()));
}
Not really possible what you want to do and it's not about Spring Data configuration, it's about Elasticsearch itself: you indexed data as not_analyzed
and it will stay that way.
Also, if you wanted case insensitive data I suggest indexing with keyword
analyzer combined with a lowercase
token filter.