我目前正在使用带有ELK 7.17.4的Spring Boot2.7.0和Spring数据弹性搜索4.4.0。在使用MultiField注释时遇到问题。获取MappingException,但注释已正确使用。注释定义和验证代码都是Spring数据弹性搜索4.4.0的一部分,因此在这里存在冲突。请参阅下面。
具有实体类:
@MultiField(mainField = @Field(type = FieldType.Text, fielddata = true, analyzer = LOWER_KEYWORD_ANALYZER, searchAnalyzer = LOWER_KEYWORD_ANALYZER),
otherFields = {
@InnerField(suffix = "sort", type = FieldType.Keyword, index = false),
@InnerField(suffix = "raw", type = FieldType.Keyword, index = false)
})
private Set<String> myProp = new HashSet<>();
```
Getting an error:
Caused by: org.springframework.data.mapping.MappingException: @Field annotation must not be used on a @MultiField property
Error stack trace:
Caused by: org.springframework.data.mapping.MappingException: @Field annotation must not be used on a @MultiField property.
at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentProperty.<init>(SimpleElasticsearchPersistentProperty.java:100) ~[spring-data-elasticsearch-4.4.0.jar:4.4.0]
at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext.createPersistentProperty(SimpleElasticsearchMappingContext.java:77) ~[spring-data-elasticsearch-4.4.0.jar:4.4.0]
at org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext.createPersistentProperty(SimpleElasticsearchMappingContext.java:34) ~[spring-data-elasticsearch-4.4.0.jar:4.4.0]
at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:603) ~[spring-data-commons-2.7.0.jar:2.7.0]
at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:581) ~[spring-data-commons-2.7.0.jar:2.7.0]
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:714) ~[spring-core-5.3.20.jar:5.3.20]
at org.springframework.data.mapping.context.AbstractMappingContext.doAddPersistentEntity(AbstractMappingContext.java:449) ~[spring-data-commons-2.7.0.jar:2.7.0]
at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:406) ~[spring-data-commons-2.7.0.jar:2.7.0]
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:291) ~[spring-data-commons-2.7.0.jar:2.7.0]
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:209) ~[spring-data-commons-2.7.0.jar:2.7.0]
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:92) ~[spring-data-commons-2.7.0.jar:2.7.0]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$6(RepositoryFactoryBeanSupport.java:325) ~[spring-data-commons-2.7.0.jar:2.7.0]
at java.util.Optional.ifPresent(Optional.java:183) ~[?:?]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:325) ~[spring-data-commons-2.7.0.jar:2.7.0]
at org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryFactoryBean.afterPropertiesSet(ElasticsearchRepositoryFactoryBean.java:69) ~[spring-data-elasticsearch-4.4.0.jar:4.4.0]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) ~[spring-beans-5.3.20.jar:5.3.20]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) ~[spring-beans-5.3.20.jar:5.3.20]
当同一属性上有多字段和字段注释时,会引发此异常。唉,您没有显示完整的实体类。
我试图从弹性搜索集群中获取数据。索引名称:testIndex类型:testType主机:localhost端口:8080 我想使用弹性搜索5.4版本,使用RestClient,我想使用多重匹配查询获取数据。 示例查询如下所示。 最好的方法是什么?我是否可以使用QueryBuilder构建查询并将其用于rest客户端。
//错误
如果我想搜索那些名字中包含巴黎的地方,我会做以下操作: 这样我就能看到所有有巴黎这个名字的地方。 然而,我如何能够搜索到其他标准的地方,如 null 在Cloud Firestore中这甚至是可能的吗?如果没有的话,有没有其他方法可以做到这一点?
我还没有为索引创建任何显式设置。谢了。
问题内容: 我要呼吁汇率第三方API,但JSON返回不断变化,如果我申请到的转换,它将返回我:,所以如果我的要求来,它将返回我。 我将不得不使用将返回的结果映射到pojo中,是否有任何可行的方法? 我当前的硬编码解决方法: 问题答案: 是具有值的字段的对象。 否是with键/值对。 两者都是正确的,但是由于before的值是动态的(变化的),因此它是您需要的第二种解释。 因此,请勿要求将JSON转