1

当我使用solrwith 时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)
4

1 回答 1

0

我修复了BaseFragmentsBuilder(必须检查 startOffset 是否大于 endOffset)并在我们的项目 Artifactory 中创建了一个修补的 JAR。排除了原始 JARpackagingExcludes并添加了修补的 JAR。我<version>像分类器一样使用标签3.6.1_patched可能更像 Maven。

好吧,这是我修补的 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。干杯马塞尔

于 2012-12-01T12:35:14.920 回答