Parsing Solr Results - javabin format

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 05:34:05

问题


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
        }

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.

Thanks for the help in advance.


回答1:


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.



来源:https://stackoverflow.com/questions/20214439/parsing-solr-results-javabin-format

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!