解析Solr结果-javabin格式 [英] Parsing Solr Results - javabin format
本文介绍了解析Solr结果-javabin格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用solrj将solr与Java集成.检索到的结果格式为
I am trying to integrate solr with java using solrj. The result retrieved are of the format
{
numFound=3,
start=0,
docs=[
SolrDocument{
id=IW-02,
name=iPod&iPodMiniUSB2.0Cable,
manu=Belkin,
manu_id_s=belkin,
cat=[
electronics,
connector
],
features=[
carpoweradapterforiPod,
white
],
weight=2.0,
price=11.5,
price_c=11.50,
USD,
popularity=1,
inStock=false,
store=37.7752,
-122.4232,
manufacturedate_dt=TueFeb1418: 55: 59EST2006,
_version_=1452625905160552448
}
现在这是javabin格式.如何从中提取结果?听说solrj确实将结果本身转换为对象.但是不知道如何.
Now this is the javabin format. How do I extract results from this? Have heard that solrj does convert the results to objects by itself. But cant figure out how.
非常感谢您的帮助.
推荐答案
让solrReply作为响应对象.您可以使用适当的参数访问结果的不同部分.假设您要使用文档,则可以执行以下操作:
Let solrReply be the response object. The you can access different parts of the result using appropriate params. Say you want docs, you can do:
docs = solrReply['docs']
如果您想要第一个结果,可以这样做:
if you want the first result you could do:
first = solrReply['docs'][0]
结果是,您可以以相同的方式访问每个字段.
Within a result you can access each field in the same way.
这篇关于解析Solr结果-javabin格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文