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 adeelmahmood <ad...@gmail.com> on 2010/02/19 16:46:04 UTC

highlighting fragments EMPTY

hi
i am trying to get highlighting working and its turning out to be a pain.
here is my schema

<field name="id" type="string" indexed="true" stored="true" required="true"
/> 
<field name="title" type="string" indexed="true" stored="true"  /> 
<field name="pi" type="string" indexed="true" stored="true" /> 
<field name="status" type="string" indexed="true" stored="true" /> 

here is the catchall field (default field for search as well)
<field name="content" type="text" indexed="true" stored="false"
multiValued="true"/>

here is how I have setup the solrconfig file
<!-- example highlighter config, enable per-query with hl=true -->
     <str name="hl.fl">title pi status</str>
     <!-- for this field, we want no fragmenting, just highlighting -->
     <str name="f.name.hl.fragsize">0</str>
     <!-- instructs Solr to return the field itself if no query terms are
          found -->
     <str name="f.title.hl.alternateField">content</str>
	 <str name="f.pi.hl.alternateField">content</str>
	 <str name="f.status.hl.alternateField">content</str>
     
	 <str name="f.title.hl.fragmenter">regex</str> <!-- defined below -->
	 <str name="f.pi.hl.fragmenter">regex</str> <!-- defined below -->
	 <str name="f.status.hl.fragmenter">regex</str> <!-- defined below -->	
	
after this when I search for lets say
http://localhost:8983/solr/select?q=submit&hl=true
I get these results in highlight section
<lst name="highlighting">
  <lst name="FP00001934" /> 
  <lst name="FP00001934-PR02" /> 
  <lst name="FP00001934-PR03" /> 
  <lst name="FP00000526" /> 
  <lst name="FP00000385" /> 
  </lst>
with no reference to the actual string .. this number thats being returned
is the id of the records .. and is also the unique identifier .. why am I
not getting the string fragments with search terms highlighted

thanks for ur help
-- 
View this message in context: http://old.nabble.com/highlighting-fragments-EMPTY-tp27654005p27654005.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: highlighting fragments EMPTY

Posted by Ahmet Arslan <io...@yahoo.com>.
> well ok I guess that makes sense and I tried changing my
> title field to text
> type and then highlighting worked on it .. but
> 1) as far as not merging all fields in catchall field and
> instead
> configuring the dismax handler to search through them .. do
> you mean then
> ill have to specify the field I want to do the search in ..
> e.g.
> q=something&hl.fl=title or
> q=somethingelse&hl.fl=status .. and another thing
> is that I have abuot 20 some fields which I am merging in
> my catch all
> fields .. with that many fields do you still think its
> better to use dismax
> or catchall field ???

You can use your previous default hl.fl definition in schema.xml.
Using dismax is more convenient because with catch all field approach you are indexing twice same data. Also with dismax you can specify separate boost factors to each field.

> 2) secondly for highlighting q=title:searchterm also didnt
> worked .. it only
> works if I change the type of title field to text instead
> of string .. even
> if I give the full string in q param .. it still doesnt
> highlights it unless
> like I said I change the field type to text ...  so
> why is that .. 

I just tested to search and highlight on my string field CATEGORY it works fine. select/?q=CATEGORY:SPOR&hl=true&hl.fl=CATEGORY

<lst name="2118883">
<arr name="CATEGORY">
<str><b>SPOR</b></str>
</arr>
</lst>

You can highlight on string type field as long as they are stored and indexed. The only this is string type is not analyzed, indexed verbatim.

> and if
> thats just how it is and I have to change some of my fields
> to text .. then
> my question is that solr will analyze them first their own
> field and then
> copy them to the catchall field while doing the analysis
> one more time ..
> since catchall field is also text .. i guess this is just
> more of a
> understanding question

Copy field definition discards source fields type. I mean it just copies raw text. Only destination field's type matters.


      

Re: highlighting fragments EMPTY

Posted by adeelmahmood <ad...@gmail.com>.
well ok I guess that makes sense and I tried changing my title field to text
type and then highlighting worked on it .. but
1) as far as not merging all fields in catchall field and instead
configuring the dismax handler to search through them .. do you mean then
ill have to specify the field I want to do the search in .. e.g.
q=something&hl.fl=title or q=somethingelse&hl.fl=status .. and another thing
is that I have abuot 20 some fields which I am merging in my catch all
fields .. with that many fields do you still think its better to use dismax
or catchall field ???

2) secondly for highlighting q=title:searchterm also didnt worked .. it only
works if I change the type of title field to text instead of string .. even
if I give the full string in q param .. it still doesnt highlights it unless
like I said I change the field type to text ...  so why is that .. and if
thats just how it is and I have to change some of my fields to text .. then
my question is that solr will analyze them first their own field and then
copy them to the catchall field while doing the analysis one more time ..
since catchall field is also text .. i guess this is just more of a
understanding question

thanks for all u guys help


Ahmet Arslan wrote:
> 
>> hi
>> i am trying to get highlighting working and its turning out
>> to be a pain.
>> here is my schema
>> 
>> <field name="id" type="string" indexed="true"
>> stored="true" required="true"
>> /> 
>> <field name="title" type="string" indexed="true"
>> stored="true"  /> 
>> <field name="pi" type="string" indexed="true"
>> stored="true" /> 
>> <field name="status" type="string" indexed="true"
>> stored="true" /> 
>> 
>> here is the catchall field (default field for search as
>> well)
>> <field name="content" type="text" indexed="true"
>> stored="false"
>> multiValued="true"/>
>> 
>> here is how I have setup the solrconfig file
>> <!-- example highlighter config, enable per-query with
>> hl=true -->
>>      <str name="hl.fl">title pi
>> status</str>
>>      <!-- for this field, we want no
>> fragmenting, just highlighting -->
>>      <str
>> name="f.name.hl.fragsize">0</str>
>>      <!-- instructs Solr to return
>> the field itself if no query terms are
>>           found -->
>>      <str
>> name="f.title.hl.alternateField">content</str>
>>      <str
>> name="f.pi.hl.alternateField">content</str>
>>      <str
>> name="f.status.hl.alternateField">content</str>
>>      
>>      <str
>> name="f.title.hl.fragmenter">regex</str> <!--
>> defined below -->
>>      <str
>> name="f.pi.hl.fragmenter">regex</str> <!--
>> defined below -->
>>      <str
>> name="f.status.hl.fragmenter">regex</str> <!--
>> defined below -->    
>>     
>> after this when I search for lets say
>> http://localhost:8983/solr/select?q=submit&hl=true
>> I get these results in highlight section
>> <lst name="highlighting">
>>   <lst name="FP00001934" /> 
>>   <lst name="FP00001934-PR02" /> 
>>   <lst name="FP00001934-PR03" /> 
>>   <lst name="FP00000526" /> 
>>   <lst name="FP00000385" /> 
>>   </lst>
>> with no reference to the actual string .. this number thats
>> being returned
>> is the id of the records .. and is also the unique
>> identifier .. why am I
>> not getting the string fragments with search terms
>> highlighted
> 
> You need to change type of fields (title, pi, staus) from string to text
> (same as content field). 
> 
> There should be a match/hit on that field in order to create highlighted
> snippets.
> 
> For example q=title:submit should return documents so that snippet of
> title can be generated.
> 
> FYI: You can search title, pi, status at the same time using
> http://wiki.apache.org/solr/DisMaxRequestHandler without copying all of
> them into a catch all field.
> 
> 
> 
> 
> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/highlighting-fragments-EMPTY-tp27654005p27661657.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: highlighting fragments EMPTY

Posted by Jan <gu...@yahoo.com>.
All of your fields seem to be of a "string" type, that's why the highlighting doesn't work. 

The highlighting fields must be tokenized before you can do the highlighting on them. 

Jan.


--- On Fri, 2/19/10, adeelmahmood <ad...@gmail.com> wrote:

From: adeelmahmood <ad...@gmail.com>
Subject: highlighting fragments EMPTY
To: solr-user@lucene.apache.org
Date: Friday, February 19, 2010, 4:46 PM


hi
i am trying to get highlighting working and its turning out to be a pain.
here is my schema

<field name="id" type="string" indexed="true" stored="true" required="true"
/> 
<field name="title" type="string" indexed="true" stored="true"  /> 
<field name="pi" type="string" indexed="true" stored="true" /> 
<field name="status" type="string" indexed="true" stored="true" /> 

here is the catchall field (default field for search as well)
<field name="content" type="text" indexed="true" stored="false"
multiValued="true"/>

here is how I have setup the solrconfig file
<!-- example highlighter config, enable per-query with hl=true -->
     <str name="hl.fl">title pi status</str>
     <!-- for this field, we want no fragmenting, just highlighting -->
     <str name="f.name.hl.fragsize">0</str>
     <!-- instructs Solr to return the field itself if no query terms are
          found -->
     <str name="f.title.hl.alternateField">content</str>
     <str name="f.pi.hl.alternateField">content</str>
     <str name="f.status.hl.alternateField">content</str>
     
     <str name="f.title.hl.fragmenter">regex</str> <!-- defined below -->
     <str name="f.pi.hl.fragmenter">regex</str> <!-- defined below -->
     <str name="f.status.hl.fragmenter">regex</str> <!-- defined below -->    
    
after this when I search for lets say
http://localhost:8983/solr/select?q=submit&hl=true
I get these results in highlight section
<lst name="highlighting">
  <lst name="FP00001934" /> 
  <lst name="FP00001934-PR02" /> 
  <lst name="FP00001934-PR03" /> 
  <lst name="FP00000526" /> 
  <lst name="FP00000385" /> 
  </lst>
with no reference to the actual string .. this number thats being returned
is the id of the records .. and is also the unique identifier .. why am I
not getting the string fragments with search terms highlighted

thanks for ur help
-- 
View this message in context: http://old.nabble.com/highlighting-fragments-EMPTY-tp27654005p27654005.html
Sent from the Solr - User mailing list archive at Nabble.com.




      

Re: highlighting fragments EMPTY

Posted by Ahmet Arslan <io...@yahoo.com>.
> hi
> i am trying to get highlighting working and its turning out
> to be a pain.
> here is my schema
> 
> <field name="id" type="string" indexed="true"
> stored="true" required="true"
> /> 
> <field name="title" type="string" indexed="true"
> stored="true"  /> 
> <field name="pi" type="string" indexed="true"
> stored="true" /> 
> <field name="status" type="string" indexed="true"
> stored="true" /> 
> 
> here is the catchall field (default field for search as
> well)
> <field name="content" type="text" indexed="true"
> stored="false"
> multiValued="true"/>
> 
> here is how I have setup the solrconfig file
> <!-- example highlighter config, enable per-query with
> hl=true -->
>      <str name="hl.fl">title pi
> status</str>
>      <!-- for this field, we want no
> fragmenting, just highlighting -->
>      <str
> name="f.name.hl.fragsize">0</str>
>      <!-- instructs Solr to return
> the field itself if no query terms are
>           found -->
>      <str
> name="f.title.hl.alternateField">content</str>
>      <str
> name="f.pi.hl.alternateField">content</str>
>      <str
> name="f.status.hl.alternateField">content</str>
>      
>      <str
> name="f.title.hl.fragmenter">regex</str> <!--
> defined below -->
>      <str
> name="f.pi.hl.fragmenter">regex</str> <!--
> defined below -->
>      <str
> name="f.status.hl.fragmenter">regex</str> <!--
> defined below -->    
>     
> after this when I search for lets say
> http://localhost:8983/solr/select?q=submit&hl=true
> I get these results in highlight section
> <lst name="highlighting">
>   <lst name="FP00001934" /> 
>   <lst name="FP00001934-PR02" /> 
>   <lst name="FP00001934-PR03" /> 
>   <lst name="FP00000526" /> 
>   <lst name="FP00000385" /> 
>   </lst>
> with no reference to the actual string .. this number thats
> being returned
> is the id of the records .. and is also the unique
> identifier .. why am I
> not getting the string fragments with search terms
> highlighted

You need to change type of fields (title, pi, staus) from string to text (same as content field). 

There should be a match/hit on that field in order to create highlighted snippets.

For example q=title:submit should return documents so that snippet of title can be generated.

FYI: You can search title, pi, status at the same time using http://wiki.apache.org/solr/DisMaxRequestHandler without copying all of them into a catch all field.