我正在尝试将solrj用于我的应用程序,我的代码在下面给出,
query.add("q", "simplify360");
query.add("facet", "true");
query.add("facet.range", "createdOnGMTDate");
query.add("facet.range.start", "2010-08-01T00:00:00Z+330MINUTES");
query.add("facet.range.end", "2011-05-31T00:00:00Z+330MINUTES");
query.add("facet.range.gap", "+1DAY");
//query.add("wt","json");
//query.add("wt.mime-type","application/json");
System.err.println(query.toString());
代码执行正常,当我在solr服务器上执行url时,我得到以下结果用于分面,
<lst name="facet_counts"><lst name="facet_queries"/>
<lst name="facet_fields"/>
<lst name="facet_dates"/>
<lst name="facet_ranges">
<lst name="createdOnGMTDate">
<lst name="counts">
<int name="2010-01-01T00:00:00Z">0</int>
<int name="2010-01-02T00:00:00Z">0</int>
<int name="2010-01-03T00:00:00Z">0</int>
<int name="2010-01-04T00:00:00Z">0</int>
<int name="2010-01-05T00:00:00Z">0</int>
<int name="2010-01-06T00:00:00Z">0</int
</lst>
<str name="gap">+1DAY</str>
<date name="start">2010-01-01T00:00:00Z</date>
<date name="end">2011-05-31T00:00:00Z</date>
</lst>
</lst>
</lst>
</response>
1)如何在java中检索这些值,
2)如果还有,我可以将json响应转换为json java对象
此致
罗希特夏尔
答案 0 :(得分:1)
使用SOLRJ API,您可以使用以下代码:
QueryResponse rsp = server.query(query); // you issue the query and get resuls
Map<String, Integer> fq = rsp.getFacetQuery(); // this returns facetQuery part of response
希望这会有所帮助......