Я пытаюсь получить объект на основе полей, которые принадлежат вложенному классу (то есть дочернему классу).Но я получаю сообщение об ошибке при выполнении запроса эластичного поиска репозитория как «NullPointerException» в консоли, хотя я передаю все необходимые параметры при вызове репозитория.
Это мой запрос к репозиторию эластичного поиска, который не может определить, что не так в этом запросек общей структуре pojo.
@Query("{\"bool\": {\"must\":[{\"match_all\":{}}],\"filter\":{\"terms\":[{\"metadata.tags\":\" ?0\"}]}}}")
Page<Episode> findByTags(String tags, Pageable pageable);
Ошибка консоли
java.lang.NullPointerException: null
at org.elasticsearch.common.ParseField.match(ParseField.java:83) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.common.ParseFieldMatcher.match(ParseFieldMatcher.java:58) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.index.query.QueryParseContext.isDeprecatedSetting(QueryParseContext.java:385) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.index.query.TermsQueryParser.parse(TermsQueryParser.java:94) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:250) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.index.query.QueryParseContext.parseInnerFilter(QueryParseContext.java:263) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.index.query.BoolQueryParser.parse(BoolQueryParser.java:91) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:250) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.index.query.IndexQueryParserService.innerParse(IndexQueryParserService.java:324) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:224) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:219) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.search.query.QueryBinaryParseElement.parse(QueryBinaryParseElement.java:36) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:856) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.search.SearchService.createContext(SearchService.java:667) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:633) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:472) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:392) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:389) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:77) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:378) ~[elasticsearch-2.4.4.jar:2.4.4]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-2.4.4.jar:2.4.4]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_181]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_181]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
Pojo Strucutre of Objects
@Entity
@JsonPropertyOrder({
"title",
"metadata",
"status",
"id",
"date"
})
@Document(indexName = "video", type = "episode", shards = 1)
public class Episode {
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
@Column(name = "id", unique = true)
@JsonProperty("id")
private String id;
@JsonProperty("title")
private String title;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "metaId")
@JsonProperty("metadata")
@Field(type = FieldType.Nested, includeInParent = true)
private Metadata metadata;
@JsonProperty("status")
private String status;
@JsonProperty("date")
private Date date;
public Episode() {
super();
}
public Episode(String title, Metadata metadata, String status, Date date) {
super();
this.title = title;
this.metadata = metadata;
this.status = status;
this.date = date;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Metadata getMetadata() {
return metadata;
}
public void setMetadata(Metadata metadata) {
this.metadata = metadata;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
@Entity
@JsonPropertyOrder({
"region",
"long_synopsis",
"meta_desc",
"tags"
})
public class Metadata {
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
@Column(name = "metaId", unique = true)
@JsonIgnore
private String metaId;
@JsonProperty("region")
private String region;
@JsonProperty("long_synopsis")
private String longSynopsis;
@JsonProperty("meta_desc")
private String metaDesc;
@Column
@ElementCollection(targetClass = String.class)
@JsonProperty("tags")
private List<String> tags;
public Metadata() {
super();
}
public Metadata(String region, String longSynopsis, String metaDesc, List<String> tags) {
super();
this.region = region;
this.longSynopsis = longSynopsis;
this.metaDesc = metaDesc;
this.tags = tags;
}
public String getMetaId() {
return metaId;
}
public void setMetaId(String metaId) {
this.metaId = metaId;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getLongSynopsis() {
return longSynopsis;
}
public void setLongSynopsis(String longSynopsis) {
this.longSynopsis = longSynopsis;
}
public String getMetaDesc() {
return metaDesc;
}
public void setMetaDesc(String metaDesc) {
this.metaDesc = metaDesc;
}
public List<String> getTags() {
return tags;
}
public void setTags(List<String> tags) {
this.tags = tags;
}
}
Пожалуйста, помогите в создании запроса с использованием аннотации для извлечения данных на основе поля из дочернего класса.