You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Bin Lan <bl...@perimeterusa.com> on 2012/12/27 21:39:45 UTC

Highlighter throws ClassCastException TextFragment cannot be cast to DocumentFragment

We have a section of code that does the text highlight, it was running fine
under lucene 1.9.1, but we are getting the following error after upgrade to
3.6.1. It does not seem to be anything that we have control of. any body
have any suggestion on how to fix this?


Exception while trying to select search results
Caused by:
java.lang.ClassCastException:
org.apache.lucene.search.highlight.TextFragment cannot be cast to
org.apache.lucene.search.highlight.DocumentFragment
	org.apache.lucene.search.highlight.FragmentQueue.lessThan(TextHighlighter.java:308)
	org.apache.lucene.util.PriorityQueue.upHeap(PriorityQueue.java:223)
	org.apache.lucene.util.PriorityQueue.add(PriorityQueue.java:132)
	org.apache.lucene.util.PriorityQueue.insertWithOverflow(PriorityQueue.java:148)
	org.apache.lucene.search.highlight.Highlighter.getBestTextFragments(Highlighter.java:324)
	org.apache.lucene.search.highlight.Highlighter.getBestFragments(Highlighter.java:158)
	org.apache.lucene.search.highlight.Highlighter.getBestFragments(Highlighter.java:134)
	com.seccas.tag.SelectSearchResultsTag.setDocMap(SelectSearchResultsTag.java:372)
	com.seccas.tag.SelectSearchResultsTag.doStartTag(SelectSearchResultsTag.java:779)



We call getBestSegments as following:

String[] fragments = highlighter.getBestFragments( analyzer, "Message",
message, mf );


Regards
--
Bin Lan
Software Developer
Perimeter E-Security
O - (203)541-3412

Follow Us on Twitter: www.twitter.com/PerimeterNews
Read Our Blog: security.perimeterusa.com/blog




This message is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information of Perimeter Internetworking Corp.  Any unauthorized review, use, copying, disclosure, or distribution is prohibited.  If you are not the intended recipient, please immediately contact the sender by reply email and delete all copies of the original message.



--
 The sender of this email subscribes to Perimeter E-Security's email
 anti-virus service. This email has been scanned for malicious code and is
 believed to be virus free. For more information on email security please
 visit: http://www.perimeterusa.com/services/messaging
 This communication is confidential, intended only for the named recipient(s)
 above and may contain trade secrets or other information that is exempt from
 disclosure under applicable law. Any use, dissemination, distribution or
 copying of this communication by anyone other than the named recipient(s) is
 strictly prohibited. If you have received this communication in error, please
 delete the email and immediately notify our Command Center at 203-541-3444.

Re: Highlighter throws ClassCastException TextFragment cannot be cast to DocumentFragment

Posted by Bin Lan <bl...@perimeterusa.com>.
Woops, please ignore this. There is a mixed version of jar file... Sorry
about this.


Regards
--
Bin Lan
Software Developer
Perimeter E-Security
O - (203)541-3412

Follow Us on Twitter: www.twitter.com/PerimeterNews
Read Our Blog: security.perimeterusa.com/blog





On Thu, Dec 27, 2012 at 3:39 PM, Bin Lan <bl...@perimeterusa.com> wrote:

> We have a section of code that does the text highlight, it was running
> fine under lucene 1.9.1, but we are getting the following error after
> upgrade to 3.6.1. It does not seem to be anything that we have control of.
> any body have any suggestion on how to fix this?
>
>
> Exception while trying to select search results
> Caused by:
> java.lang.ClassCastException: org.apache.lucene.search.highlight.TextFragment cannot be cast to org.apache.lucene.search.highlight.DocumentFragment
> 	org.apache.lucene.search.highlight.FragmentQueue.lessThan(TextHighlighter.java:308)
> 	org.apache.lucene.util.PriorityQueue.upHeap(PriorityQueue.java:223)
> 	org.apache.lucene.util.PriorityQueue.add(PriorityQueue.java:132)
> 	org.apache.lucene.util.PriorityQueue.insertWithOverflow(PriorityQueue.java:148)
> 	org.apache.lucene.search.highlight.Highlighter.getBestTextFragments(Highlighter.java:324)
> 	org.apache.lucene.search.highlight.Highlighter.getBestFragments(Highlighter.java:158)
> 	org.apache.lucene.search.highlight.Highlighter.getBestFragments(Highlighter.java:134)
> 	com.seccas.tag.SelectSearchResultsTag.setDocMap(SelectSearchResultsTag.java:372)
> 	com.seccas.tag.SelectSearchResultsTag.doStartTag(SelectSearchResultsTag.java:779)
>
>
>
> We call getBestSegments as following:
>
> String[] fragments = highlighter.getBestFragments( analyzer, "Message",
> message, mf );
>
>
> Regards
> --
> Bin Lan
> Software Developer
> Perimeter E-Security
> O - (203)541-3412
>
> Follow Us on Twitter: www.twitter.com/PerimeterNews
> Read Our Blog: security.perimeterusa.com/blog
>
>
>
>




This message is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information of Perimeter Internetworking Corp.  Any unauthorized review, use, copying, disclosure, or distribution is prohibited.  If you are not the intended recipient, please immediately contact the sender by reply email and delete all copies of the original message.



--
 The sender of this email subscribes to Perimeter E-Security's email
 anti-virus service. This email has been scanned for malicious code and is
 believed to be virus free. For more information on email security please
 visit: http://www.perimeterusa.com/services/messaging
 This communication is confidential, intended only for the named recipient(s)
 above and may contain trade secrets or other information that is exempt from
 disclosure under applicable law. Any use, dissemination, distribution or
 copying of this communication by anyone other than the named recipient(s) is
 strictly prohibited. If you have received this communication in error, please
 delete the email and immediately notify our Command Center at 203-541-3444.