【发布时间】:2017-08-27 11:20:29
【问题描述】:
我目前正在使用 MarkLogic POJO 数据绑定接口。我能够将 POJO 写入 MarkLogic。现在我想搜索那些 POJO 并检索搜索结果。我正在按照以下说明进行操作:https://docs.marklogic.com/guide/java/binding#id_89573 但是,搜索结果似乎没有返回正确的对象。我收到了 JSONMappingException。代码如下:
HashMap<String, MatchedPropertyInfo> matchedProperties = new HashMap<String, MatchedPropertyInfo>();
PropertyMatches PM = new PropertyMatches(123,"uri/prefix/location2", "uri/prefix", 1234,0,"/aKey","/aLocation",true,matchedProperties);
MatchedPropertyInfo MPI1 = new MatchedPropertyInfo("matched/property/uri1", "matched/property/key1", "matched/property/location1", true,"ValueMatch1", 12, 1*1.0/3, true);
MatchedPropertyInfo MPI2 = new MatchedPropertyInfo("matched/property/uri2", "matched/property/key2", "matched/property/location2", true,"ValueMatch2", 14, 1.0/2.0, true);
PM.getMatchedProperties().put("matched/property/prefix/location1", MPI1);
PM.getMatchedProperties().put("matched/property/prefix/location2", MPI2);
PojoRepository myClassRepo = client.newPojoRepository(PropertyMatches.class, Long.class);
myClassRepo.write(PM);
PojoQueryBuilder qb = myClassRepo.getQueryBuilder();
PojoPage<PropertyMatches> matches = myClassRepo.search(qb.value("uri", "uri/prefix/location2"),1);
if (matches.hasContent()) {
while (matches.hasNext()) {
PropertyMatches aPM = matches.next();
System.out.println(" " + aPM.getURI());
}
} else {
System.out.println(" No matches");
}
PropertyMatches (PM) 对象已成功写入 MarkLogic 数据库。此类包含一个成员:private String URI,它以"uri/prefix/location2" 启动。 matches.hasContent() 在上面的示例中返回 true。但是,我在PropertyMatches aPM = matches.next(); 上遇到错误
【问题讨论】: