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 Stephen Green <ee...@gmail.com> on 2009/08/04 02:05:36 UTC

Highlighting question

Hi, folks.  I'm trying to get a very simple example working with Solr
highlighting.  I have a default search field (called, unsurprisingly
"default-search-field") with text in it and I want query terms to be
highlighted in that field when I do a search.

I'm using an up to date (as of this evening) checkout of 1.4.  My
solrconfig.xml contains the following highlighting element:

    <highlighting>
   <!-- Configure the standard fragmenter -->
   <!-- This could most likely be commented out in the "default" case -->
        <fragmenter name="gap"
class="org.apache.solr.highlight.GapFragmenter" default="true">
            <lst name="defaults">
                <int name="hl.fragsize">200</int>
            </lst>
        </fragmenter>

   <!-- A regular-expression-based fragmenter (f.i., for sentence
extraction) -->
        <fragmenter name="regex"
class="org.apache.solr.highlight.RegexFragmenter">
            <lst name="defaults">
      <!-- slightly smaller fragsizes work better because of slop -->
                <int name="hl.fragsize">170</int>
      <!-- allow 50% slop on fragment sizes -->
                <float name="hl.regex.slop">0.5</float>
      <!-- a basic sentence pattern -->
                <str name="hl.regex.pattern">[-\w ,/\n\"']{20,200}</str>
            </lst>
        </fragmenter>

   <!-- Configure the standard formatter -->
        <formatter name="html"
class="org.apache.solr.highlight.HtmlFormatter" default="true">
            <lst name="defaults">
                <str name="hl.simple.pre"><![CDATA[<span class="ht">]]>
                </str>
                <str name="hl.simple.post"><![CDATA[</span>]]>
                </str>
            </lst>
        </formatter>
    </highlighting>

I'm using SolrJ to talk to the Solr server.  Here's the code to do a
query, where qs is the query string.

            SolrQuery q = new SolrQuery(qs);
            q.setQueryType("dismax");
            q.setHighlight(true);
            q.setHighlightFragsize(250);
            q.set("hl.formatter", "html");
            q.set("hl.fragmenter", "regex");
            q.setFields("default-search-field", "key");
            QueryResponse resp = solr.query(q);

I've set up the dismax handler in solrconfig.xml to search the
default-search-field.

The Solr server logs the following request for this:

INFO: [] webapp=/solr path=/select
params={hl.fragsize=250&fl=default-search-field,key&hl.fragmenter=regex&q=garbage&hl.formatter=html&qt=dismax&wt=javabin&hl=true&version=1}
hits=953 status=0 QTime=39

which looks about right to me, but I don't see any highlighting in the results.

I'm clearly missing something pretty fundamental here, and any help
would be appreciated.

Steve Green

Re: Highlighting question

Posted by ewinclub7 <ew...@hotmail.com>.
 หากคุณไม่ต้องการที่จะเล่นต่อแล้วก็สามารถที่จะ
ผลของเกมส์ฟุตบอลทั้งหมดจะถูกตัดสินหลังจากผู้เล่นเต็มเวลาครบเก้าสิบนาที
ซึ้งส่วนใหญ่จะใช้เวลาไม่เกินสองชั่วโมงครึ่ง
ทั้งนี้ทั้งนั้นก็ขึ้นอยู่กับข้อตกลงของผู้ให้คำชี้แนะด้วย  goldclub slot
<http://www.goldclub.net/>   Software ที่ใช้ จะต้องได้รับรองมาตราฐานระดับโลก
ซึ่งจำเป็นสำหรับผู้เล่นที่เข้าร่วมสนุกกับเรา  royal1688 สมัคร
<http://www.royal1688.org/register/>  
พอดีแวะไปเจออย่างไรบางอย่างในเว็บไซต์ของ  royal1688 download
<http://www.royal1688.net/download/>   เศรษฐกิจของประเทศต่างๆ ที่มีคาสิโน
หลายคนอาจจะกำลังสงสัย และอยากทราบว่า คาสิโน
ในประเทศต่างๆนั้นถือว่าเป็นธุรกิจที่สำคัญหรือไม่



--
View this message in context: http://lucene.472066.n3.nabble.com/Highlighting-question-tp501425p4095210.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Highlighting question

Posted by ewinclub7 <ew...@hotmail.com>.
อันดับแรกให้เช็คก่อนว่า คุณมีจำนวนเงินขั้นต่ำพอที่จะถอนหรือไม่
ก้าวขึ้นมาครองใจผู้บริโภคดีที่สุดในประเทศไทย
ยิ่งเป็นกลุ่มคนสมัยใหม่แล้วยิ่งชอบ
แต่เมื่อนักเล่นสมัยใหม่ได้สัมผัสกับวิธีเล่นออนไลน์แล้ว
ทำให้นักเล่นมีความชื่นชมชื่นชอบเป็นอย่างยิ่ง  พนันบอล
<http://livescore.zohosites.com/sport-bet.html>   เป็นผู้ให้คำแนะนำออนไลน์
และยังได้รับรองมาตราฐานสากล มีใบอนุญาตการให้แนวทางอย่างถูกฏหมาย 
เช็คผลบอลวันนี้ <http://polball.zohosites.com/>  
และเราไม่ประสงค์จะให้บุคคลใดกระทำการช่อโกงหรือส่อไปในทางช่อโกงกับเราในทุกรูปแบบ 
บาคาร่า <http://livescore.zohosites.com/casino-online.html>  
ที่จะทำให้ผู้เล่นเกิดความไว้วางใจมากขึ้นจากการเล่นพนันในฐานะการเรียนรู้รับประสบการณ์ใหม่ๆจากรูปแบบของการแทงในวิถีของการออนไลน์ล่ะค่ะ
หลังจาก Login ท่านสามารถตรวจสอบ ยอดเงินของท่าน ใน ยอดคงเหลือ
ในเมนูด้านบนหรือวางพนันฟุตบอลในเมนูกีฬาด้านซ้ายมือ
เรายืนยันได้ว่าทางเราไม่มีการควบคุมเกมส์ และผลที่จะเกิดขึ้นของเกมส์ต่างๆ
หากคุณต้องการที่จะตรวจสอบเราก่อนที่คุณจะเล่นด้วยเงินจริง  แทงบอลสเต็ป
<http://sbobet.zohosites.com/ballstep.html>   แน่นอนว่าคนเราหากเล่น
คาสิโนออนไลน์ แล้วชนะได้เล่นชนะได้เล่นรางวัลแล้ว  สมัครบาคาร่า
<http://livescore.zohosites.com/register.html>   คุณมั่นใจเราได้
เราใช้นวัตกรรมเทคโนโลยีเกมส์ออนไลน์
ที่ได้รับมาตราฐานมีความปลอดภัยด้วยการใช้เทคโนโลยีที่ซับซ้อนในการเข้ารหัส
รวมทั้งไฟร์วอลล์และเทคโนโลยีป้องกันความปลอดภัยของรายละเอียดส่วนบุคคล



--
View this message in context: http://lucene.472066.n3.nabble.com/Highlighting-question-tp501425p4093238.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Highlighting question

Posted by Stephen Green <ee...@gmail.com>.
On Mon, Aug 3, 2009 at 8:45 PM, Stephen Green<ee...@gmail.com> wrote:
> On Mon, Aug 3, 2009 at 8:38 PM, Stephen Green<ee...@gmail.com> wrote:
>> On Mon, Aug 3, 2009 at 8:34 PM, Erik Hatcher<er...@ehatchersolutions.com> wrote:
>>> Is default-search-field stored (as specified in schema.xml)?
>>
>> Yep:
>>
>>    <field name="default-search-field"
>>        type="html" indexed="true" stored="true"
>>        termVectors="true" multiValued="true"/>
>>
>> While trying to figure this out, I went and did ant run-examples to
>> bring up the example in Jetty (I'm using Tomcat), and tried a couple
>> of queries in the resulting /solr/admin, and they don't appear to be
>> highlighted either.
>
> Actually, if I check the highlighting box in the "full interface"
> query option in the Solr admin panel, I notice that an element like:
>
> <lst name="highlighting">
> <lst name="SOLR1000"/>
> </lst>
>
> Is added to the end of the results that are returned.
>
> Oh, and thanks for the fast response, Erik :-)

OK, I think I might just be dumb.  The query response has a set of
highlighted things with references to the docs that were highlighted.
There's enough information there to create the highlighted
representation that I want.

Duh.

Steve Green

Re: Highlighting question

Posted by Stephen Green <ee...@gmail.com>.
On Mon, Aug 3, 2009 at 8:38 PM, Stephen Green<ee...@gmail.com> wrote:
> On Mon, Aug 3, 2009 at 8:34 PM, Erik Hatcher<er...@ehatchersolutions.com> wrote:
>> Is default-search-field stored (as specified in schema.xml)?
>
> Yep:
>
>    <field name="default-search-field"
>        type="html" indexed="true" stored="true"
>        termVectors="true" multiValued="true"/>
>
> While trying to figure this out, I went and did ant run-examples to
> bring up the example in Jetty (I'm using Tomcat), and tried a couple
> of queries in the resulting /solr/admin, and they don't appear to be
> highlighted either.

Actually, if I check the highlighting box in the "full interface"
query option in the Solr admin panel, I notice that an element like:

<lst name="highlighting">
<lst name="SOLR1000"/>
</lst>

Is added to the end of the results that are returned.

Oh, and thanks for the fast response, Erik :-)

Steve Green

Re: Highlighting question

Posted by Stephen Green <ee...@gmail.com>.
On Mon, Aug 3, 2009 at 8:34 PM, Erik Hatcher<er...@ehatchersolutions.com> wrote:
> Is default-search-field stored (as specified in schema.xml)?

Yep:

    <field name="default-search-field"
        type="html" indexed="true" stored="true"
        termVectors="true" multiValued="true"/>

While trying to figure this out, I went and did ant run-examples to
bring up the example in Jetty (I'm using Tomcat), and tried a couple
of queries in the resulting /solr/admin, and they don't appear to be
highlighted either.

Steve Green

Re: Highlighting question

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
Is default-search-field stored (as specified in schema.xml)?

	Erik


On Aug 3, 2009, at 8:05 PM, Stephen Green wrote:

> Hi, folks.  I'm trying to get a very simple example working with Solr
> highlighting.  I have a default search field (called, unsurprisingly
> "default-search-field") with text in it and I want query terms to be
> highlighted in that field when I do a search.
>
> I'm using an up to date (as of this evening) checkout of 1.4.  My
> solrconfig.xml contains the following highlighting element:
>
>    <highlighting>
>   <!-- Configure the standard fragmenter -->
>   <!-- This could most likely be commented out in the "default" case  
> -->
>        <fragmenter name="gap"
> class="org.apache.solr.highlight.GapFragmenter" default="true">
>            <lst name="defaults">
>                <int name="hl.fragsize">200</int>
>            </lst>
>        </fragmenter>
>
>   <!-- A regular-expression-based fragmenter (f.i., for sentence
> extraction) -->
>        <fragmenter name="regex"
> class="org.apache.solr.highlight.RegexFragmenter">
>            <lst name="defaults">
>      <!-- slightly smaller fragsizes work better because of slop -->
>                <int name="hl.fragsize">170</int>
>      <!-- allow 50% slop on fragment sizes -->
>                <float name="hl.regex.slop">0.5</float>
>      <!-- a basic sentence pattern -->
>                <str name="hl.regex.pattern">[-\w ,/\n\"']{20,200}</ 
> str>
>            </lst>
>        </fragmenter>
>
>   <!-- Configure the standard formatter -->
>        <formatter name="html"
> class="org.apache.solr.highlight.HtmlFormatter" default="true">
>            <lst name="defaults">
>                <str name="hl.simple.pre"><![CDATA[<span class="ht">]]>
>                </str>
>                <str name="hl.simple.post"><![CDATA[</span>]]>
>                </str>
>            </lst>
>        </formatter>
>    </highlighting>
>
> I'm using SolrJ to talk to the Solr server.  Here's the code to do a
> query, where qs is the query string.
>
>            SolrQuery q = new SolrQuery(qs);
>            q.setQueryType("dismax");
>            q.setHighlight(true);
>            q.setHighlightFragsize(250);
>            q.set("hl.formatter", "html");
>            q.set("hl.fragmenter", "regex");
>            q.setFields("default-search-field", "key");
>            QueryResponse resp = solr.query(q);
>
> I've set up the dismax handler in solrconfig.xml to search the
> default-search-field.
>
> The Solr server logs the following request for this:
>
> INFO: [] webapp=/solr path=/select
> params={hl.fragsize=250&fl=default-search- 
> field 
> ,key 
> &hl 
> .fragmenter 
> = 
> regex 
> &q=garbage&hl.formatter=html&qt=dismax&wt=javabin&hl=true&version=1}
> hits=953 status=0 QTime=39
>
> which looks about right to me, but I don't see any highlighting in  
> the results.
>
> I'm clearly missing something pretty fundamental here, and any help
> would be appreciated.
>
> Steve Green