Модель:
@AllArgsConstructor
@NoArgsConstructor
@Data
//@Setting(settingPath = "settings/settings.json")
@Document(indexName = "address", createIndex = true)
public class Address {
@Id
private String id;
// @Field(type = FieldType.Text, analyzer = "ngram_analyzer", searchAnalyzer = "lowercasespaceanalyzer")
@MultiField(mainField = @Field(type = FieldType.Text, fielddata = true))
private String fullAddress;
@Field(type = FieldType.Integer)
private String regionCode;
@Field(type = FieldType.Nested, store = true)
private List<Entry> parts;
public Address(String fullAddress) {
this.fullAddress = fullAddress;
}
public Address(String fullAddress, List<Entry> entryList) {
this.fullAddress = fullAddress;
this.parts = entryList;
}
public Address(String fullAddress, List<Entry> entryList, String regionCode) {
this.fullAddress = fullAddress;
this.parts = entryList;
this.regionCode = regionCode;
}
}
Репозиторий
@Repository
public interface AddressElasticRepository extends ElasticsearchRepository<Address, String> {
List<Address> findByFullAddressContains(String fullAddress);
}
Сервис
@Override
public List<Address> search(String query) {
List<Address> all = addressElasticRepository.findByFullAddressContains(query);
all.forEach(it -> log.info("-- " + it));
return all;
}
Я получаю сообщение об ошибке:
орг. springframework.dao.InvalidDataAccessApiUsageException: Невозможно построить запрос ' "Россия Москва" '. Вместо этого используйте выражение или несколько предложений. at org.springframework.data.elasticsearch.core.query.Criteria.assertNoBlankInWildcardedQuery (Criteria. java: 522) ~ [spring-data -asticsearch-4.0.0.BUILD-20200217.043541-321.jar: 4.0.0.BUILD -SNAPSHOT] at org.springframework.data.elasticsearch.core.query.Criteria.contains (Критерии. java: 237) ~ [spring-data -asticsearch-4.0.0.BUILD-20200217.043541-321.jar: 4.0. 0.BUILD-SNAPSHOT. .jar: 4.0.0.BUILD-SNAPSHOT] at org.springframework.data.elasticsearch.repository.query.parser.ElasticsearchQueryCreator.create (ElasticsearchQueryCreator. java: 67) ~ [spring-data -asticsearch-4.0.0. BUILD-20200217.043541-321.jar: 4.0.0.BUILD-SNAPSHOT] at org.springframework.data.elasticsearch.repository.query.parser.ElasticsearchQueryCreator.create (ElasticsearchQueryCreator. java: 48-упругих данных-пружинных-данных) -4.0.0.BUILD-202 00217.043541-321.jar: 4.0.0.BUILD-SNAPSHOT] at org.springframework.data.repository.query.parser.AbstractQueryCreator.createCriteria (AbstractQueryCreator. java: 119) ~ [spring-data-commons-2.1.10 .RELEASE.jar: 2.1.10.RELEASE] at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery (AbstractQueryCreator. java: 95) ~ [spring-data-commons-2.1.10.RELEASE. jar: 2.1.10.RELEASE] at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery (AbstractQueryCreator. java: 81) ~ [spring-data-commons-2.1.10.RELEASE.jar: 2.1 .10.RELEASE]
Как это исправить, продолжая использовать Spring-data?