当solr
与useFastVectorHighlighter = true
一起使用时,我遇到了一些错误。
这是我的查询日志:
[user] webapp= path=/select params={mm=1&hl.tag.post=</b>&qf=firstName+nickName^5+lastName&hl.tag.pre=<b>&wt=javabin&hl=true&version=2&rows=100&defType=dismax&hl.highlightMultiTerm=true&hl.useFastVectorHighlighter=true&start=0&q=a+bc&hl.boundaryScanner=breakIterator} hits=3767 status=500 QTime=266 ,someone can help me? but query with abc(without blank) is ok.
java.lang.StringIndexOutOfBoundsException: String index out of range: -6
at java.lang.String.substring(Unknown Source)
at org.apache.lucene.search.vectorhighlight.BaseFragmentsBuilder.makeFragment(BaseFragmentsBuilder.java:166)
at org.apache.lucene.search.vectorhighlight.BaseFragmentsBuilder.createFragments(BaseFragmentsBuilder.java:115)
at org.apache.lucene.search.vectorhighlight.FastVectorHighlighter.getBestFragments(FastVectorHighlighter.java:186)
at org.apache.solr.highlight.DefaultSolrHighlighter.doHighlightingByFastVectorHighlighter(DefaultSolrHighlighter.java:532)
at org.apache.solr.highlight.DefaultSolrHighlighter.doHighlighting(DefaultSolrHighlighter.java:399)
at org.apache.solr.handler.component.HighlightComponent.process(HighlightComponent.java:131)
at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:186)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1376)
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:365)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:260)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
答案 0 :(得分:0)
我修复了BaseFragmentsBuilder
(必须检查startOffset是否大于endOffset)并在我们的项目Artifactory中创建了一个修补过的JAR。使用packagingExcludes
排除了原始JAR,并添加了已修补的JAR。我使用<version>
标记,如3.6.1_patched
,分类器可能更有可能。
好here is a link to my patched JAR.
主要是我对偏移进行了一些范围检查。 if语句修复了这个错误。
int startOffset = to.getStartOffset() - modifiedStartOffset[0] < 0 ? 0 : to.getStartOffset() - modifiedStartOffset[0];
int endOffset = to.getEndOffset() - modifiedStartOffset[0] > src.length()-1 ? src.length()-1 : to.getEndOffset() - modifiedStartOffset[0];
if (srcIndex < startOffset) {
fragment
.append(encoder.encodeText(src.substring(srcIndex, startOffset)))
.append( getPreTag( preTags, subInfo.getSeqnum() ) )
.append( encoder.encodeText( src.substring(startOffset, endOffset ) ) )
.append( getPostTag( postTags, subInfo.getSeqnum() ) );
}
srcIndex = endOffset;
希望这可以帮助您使用FastVectorHighlighter。 干杯 烫发