You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Ruixiang Zhang <rx...@gmail.com> on 2010/12/23 03:56:25 UTC

Print highlighting descriptions

I want to print the highlighting descriptions:

{"responseHeader":{"status":0,
"QTime":2,"params":{"hl.fl":"description","json.wrf":"jsonp1293069622009","wt":"json","q":"target","hl":"true"}},"response":{"numFound":7945,"start":0,"maxScore":6.9186745,"docs":[{"description":"target","url":"target","id":"269653","score":6.9186745},{"description":"Target
The
Woodlands","url":"Target_The_Woodlands","id":"37277","score":4.3241715},{"description":"Target
Kent","url":"Target_Kent","id":"37275","score":4.3241715}]},
"highlighting":{"269653":{"description":["<em>target</em>
"]},"37277":{"description":["<em>Target</em> The
Woodlands"]},"37275":{"description":["<em>Target</em>
Kent"]}}}

I know the descriptions in docs is:  response.response.docs[i].description
But I don't know how to print out the highlighting descriptions, such as
"<em>Target</em> Kent" (No need to highlight, just print out).

Thanks
Ruixiang

Re: Print highlighting descriptions

Posted by Ruixiang Zhang <rx...@gmail.com>.
Hi Koji

I figured it out. I can use
response.highlighting[response.response.docs[0].id].description[0]
to print the description in highlighting.

(Actually, it's not a solr question, sorry for that.)

Thanks
Ruixiang

On Wed, Dec 22, 2010 at 10:05 PM, Koji Sekiguchi <ko...@r.email.ne.jp> wrote:

> (10/12/23 14:10), Ruixiang Zhang wrote:
>
>> Thanks Koji. Actually my question is:
>>
>> We can use  response.response.docs[i].description
>> to print the description in docs.
>>
>> What expression should we use to print the description in highlighting?
>>
>
> Ruixiang,
>
> I cannot understand your question. Is it Solr question? :)
> You said "No need to highlight, just print out" in your previous mail,
> then asked above???
>
> What do you mean by "expression" and "print"?
>
>
> Koji
> --
> http://www.rondhuit.com/en/
>

Re: Print highlighting descriptions

Posted by Koji Sekiguchi <ko...@r.email.ne.jp>.
(10/12/23 14:10), Ruixiang Zhang wrote:
> Thanks Koji. Actually my question is:
>
> We can use  response.response.docs[i].description
> to print the description in docs.
>
> What expression should we use to print the description in highlighting?

Ruixiang,

I cannot understand your question. Is it Solr question? :)
You said "No need to highlight, just print out" in your previous mail,
then asked above???

What do you mean by "expression" and "print"?

Koji
-- 
http://www.rondhuit.com/en/

Re: Print highlighting descriptions

Posted by Ruixiang Zhang <rx...@gmail.com>.
Thanks Koji. Actually my question is:

We can use  response.response.docs[i].description
to print the description in docs.

What expression should we use to print the description in highlighting?

Re: Print highlighting descriptions

Posted by Koji Sekiguchi <ko...@r.email.ne.jp>.
(10/12/23 11:56), Ruixiang Zhang wrote:
> I want to print the highlighting descriptions:
>
> {"responseHeader":{"status":0,
> "QTime":2,"params":{"hl.fl":"description","json.wrf":"jsonp1293069622009","wt":"json","q":"target","hl":"true"}},"response":{"numFound":7945,"start":0,"maxScore":6.9186745,"docs":[{"description":"target","url":"target","id":"269653","score":6.9186745},{"description":"Target
> The
> Woodlands","url":"Target_The_Woodlands","id":"37277","score":4.3241715},{"description":"Target
> Kent","url":"Target_Kent","id":"37275","score":4.3241715}]},
> "highlighting":{"269653":{"description":["<em>target</em>
> "]},"37277":{"description":["<em>Target</em>  The
> Woodlands"]},"37275":{"description":["<em>Target</em>
> Kent"]}}}
>
> I know the descriptions in docs is:  response.response.docs[i].description
> But I don't know how to print out the highlighting descriptions, such as
> "<em>Target</em>  Kent" (No need to highlight, just print out).

Ruixiang,

If you meant that you want to get "Target Kent" instead of "<em>Target</em>  Kent",
you can change <em> tags to empty string by using hl.simple.pre/hl.simple.post
parameters:

http://wiki.apache.org/solr/HighlightingParameters#hl.simple.pre.2BAC8-hl.simple.post

Koji
-- 
http://www.rondhuit.com/en/