elasticsearch fails to start due to verification error, closes #2051.

This commit is contained in:
Shay Banon 2012-06-25 17:00:01 +02:00
parent e523c71a88
commit c0f9e337ce
6 changed files with 114 additions and 115 deletions

View File

@ -1,78 +0,0 @@
package org.apache.lucene.search.vectorhighlight;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.search.vectorhighlight.FieldFragList.WeightedFragInfo;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* An implementation of FragmentsBuilder that outputs score-order fragments.
*/
public class ScoreOrderFragmentsBuilder extends AbstractFragmentsBuilder {
/**
* a constructor.
*/
public ScoreOrderFragmentsBuilder(){
super();
}
/**
* a constructor.
*
* @param preTags array of pre-tags for markup terms.
* @param postTags array of post-tags for markup terms.
*/
public ScoreOrderFragmentsBuilder(String[] preTags, String[] postTags){
super( preTags, postTags );
}
public ScoreOrderFragmentsBuilder(BoundaryScanner bs){
super( bs );
}
public ScoreOrderFragmentsBuilder(String[] preTags, String[] postTags, BoundaryScanner bs){
super( preTags, postTags, bs );
}
/**
* Sort by score the list of WeightedFragInfo
*/
@Override
public List<WeightedFragInfo> getWeightedFragInfoList( List<WeightedFragInfo> src ) {
Collections.sort( src, new ScoreComparator() );
return src;
}
public static class ScoreComparator implements Comparator<WeightedFragInfo> {
public int compare( WeightedFragInfo o1, WeightedFragInfo o2 ) {
if( o1.totalBoost > o2.totalBoost ) return -1;
else if( o1.totalBoost < o2.totalBoost ) return 1;
// if same score then check startOffset
else{
if( o1.startOffset < o2.startOffset ) return -1;
else if( o1.startOffset > o2.startOffset ) return 1;
}
return 0;
}
}
}

View File

@ -0,0 +1,78 @@
package org.apache.lucene.search.vectorhighlight;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.search.vectorhighlight.FieldFragList.WeightedFragInfo;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* An implementation of FragmentsBuilder that outputs score-order fragments.
*/
public class XScoreOrderFragmentsBuilder extends AbstractFragmentsBuilder {
/**
* a constructor.
*/
public XScoreOrderFragmentsBuilder() {
super();
}
/**
* a constructor.
*
* @param preTags array of pre-tags for markup terms.
* @param postTags array of post-tags for markup terms.
*/
public XScoreOrderFragmentsBuilder(String[] preTags, String[] postTags) {
super(preTags, postTags);
}
public XScoreOrderFragmentsBuilder(BoundaryScanner bs) {
super(bs);
}
public XScoreOrderFragmentsBuilder(String[] preTags, String[] postTags, BoundaryScanner bs) {
super(preTags, postTags, bs);
}
/**
* Sort by score the list of WeightedFragInfo
*/
@Override
public List<WeightedFragInfo> getWeightedFragInfoList(List<WeightedFragInfo> src) {
Collections.sort(src, new ScoreComparator());
return src;
}
public static class ScoreComparator implements Comparator<WeightedFragInfo> {
public int compare(WeightedFragInfo o1, WeightedFragInfo o2) {
if (o1.totalBoost > o2.totalBoost) return -1;
else if (o1.totalBoost < o2.totalBoost) return 1;
// if same score then check startOffset
else {
if (o1.startOffset < o2.startOffset) return -1;
else if (o1.startOffset > o2.startOffset) return 1;
}
return 0;
}
}
}

View File

@ -23,40 +23,39 @@ import java.util.List;
/** /**
* A simple implementation of FragmentsBuilder. * A simple implementation of FragmentsBuilder.
*
*/ */
public class SimpleFragmentsBuilder extends AbstractFragmentsBuilder { public class XSimpleFragmentsBuilder extends AbstractFragmentsBuilder {
/** /**
* a constructor. * a constructor.
*/ */
public SimpleFragmentsBuilder() { public XSimpleFragmentsBuilder() {
super(); super();
} }
/** /**
* a constructor. * a constructor.
* *
* @param preTags array of pre-tags for markup terms. * @param preTags array of pre-tags for markup terms.
* @param postTags array of post-tags for markup terms. * @param postTags array of post-tags for markup terms.
*/ */
public SimpleFragmentsBuilder(String[] preTags, String[] postTags) { public XSimpleFragmentsBuilder(String[] preTags, String[] postTags) {
super( preTags, postTags ); super(preTags, postTags);
} }
public SimpleFragmentsBuilder(BoundaryScanner bs) { public XSimpleFragmentsBuilder(BoundaryScanner bs) {
super( bs ); super(bs);
} }
public SimpleFragmentsBuilder(String[] preTags, String[] postTags, BoundaryScanner bs) { public XSimpleFragmentsBuilder(String[] preTags, String[] postTags, BoundaryScanner bs) {
super( preTags, postTags, bs ); super(preTags, postTags, bs);
} }
/** /**
* do nothing. return the source list. * do nothing. return the source list.
*/ */
@Override @Override
public List<WeightedFragInfo> getWeightedFragInfoList( List<WeightedFragInfo> src ) { public List<WeightedFragInfo> getWeightedFragInfoList(List<WeightedFragInfo> src) {
return src; return src;
} }
} }

View File

@ -265,7 +265,7 @@ public class HighlightPhase extends AbstractComponent implements FetchSubPhase {
fragListBuilder = new SingleFragListBuilder(); fragListBuilder = new SingleFragListBuilder();
if (mapper.stored()) { if (mapper.stored()) {
fragmentsBuilder = new SimpleFragmentsBuilder(field.preTags(), field.postTags(), boundaryScanner); fragmentsBuilder = new XSimpleFragmentsBuilder(field.preTags(), field.postTags(), boundaryScanner);
} else { } else {
fragmentsBuilder = new SourceSimpleFragmentsBuilder(mapper, context, field.preTags(), field.postTags(), boundaryScanner); fragmentsBuilder = new SourceSimpleFragmentsBuilder(mapper, context, field.preTags(), field.postTags(), boundaryScanner);
} }
@ -277,13 +277,13 @@ public class HighlightPhase extends AbstractComponent implements FetchSubPhase {
if (field.scoreOrdered()) { if (field.scoreOrdered()) {
if (mapper.stored()) { if (mapper.stored()) {
fragmentsBuilder = new ScoreOrderFragmentsBuilder(field.preTags(), field.postTags(), boundaryScanner); fragmentsBuilder = new XScoreOrderFragmentsBuilder(field.preTags(), field.postTags(), boundaryScanner);
} else { } else {
fragmentsBuilder = new SourceScoreOrderFragmentsBuilder(mapper, context, field.preTags(), field.postTags(), boundaryScanner); fragmentsBuilder = new SourceScoreOrderFragmentsBuilder(mapper, context, field.preTags(), field.postTags(), boundaryScanner);
} }
} else { } else {
if (mapper.stored()) { if (mapper.stored()) {
fragmentsBuilder = new SimpleFragmentsBuilder(field.preTags(), field.postTags(), boundaryScanner); fragmentsBuilder = new XSimpleFragmentsBuilder(field.preTags(), field.postTags(), boundaryScanner);
} else { } else {
fragmentsBuilder = new SourceSimpleFragmentsBuilder(mapper, context, field.preTags(), field.postTags(), boundaryScanner); fragmentsBuilder = new SourceSimpleFragmentsBuilder(mapper, context, field.preTags(), field.postTags(), boundaryScanner);
} }

View File

@ -22,7 +22,7 @@ package org.elasticsearch.search.highlight.vectorhighlight;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.vectorhighlight.BoundaryScanner; import org.apache.lucene.search.vectorhighlight.BoundaryScanner;
import org.apache.lucene.search.vectorhighlight.ScoreOrderFragmentsBuilder; import org.apache.lucene.search.vectorhighlight.XScoreOrderFragmentsBuilder;
import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.search.lookup.SearchLookup; import org.elasticsearch.search.lookup.SearchLookup;
@ -33,7 +33,7 @@ import java.util.List;
/** /**
* *
*/ */
public class SourceScoreOrderFragmentsBuilder extends ScoreOrderFragmentsBuilder { public class SourceScoreOrderFragmentsBuilder extends XScoreOrderFragmentsBuilder {
private final FieldMapper mapper; private final FieldMapper mapper;

View File

@ -22,7 +22,7 @@ package org.elasticsearch.search.highlight.vectorhighlight;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.vectorhighlight.BoundaryScanner; import org.apache.lucene.search.vectorhighlight.BoundaryScanner;
import org.apache.lucene.search.vectorhighlight.SimpleFragmentsBuilder; import org.apache.lucene.search.vectorhighlight.XSimpleFragmentsBuilder;
import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.search.lookup.SearchLookup; import org.elasticsearch.search.lookup.SearchLookup;
@ -33,7 +33,7 @@ import java.util.List;
/** /**
* *
*/ */
public class SourceSimpleFragmentsBuilder extends SimpleFragmentsBuilder { public class SourceSimpleFragmentsBuilder extends XSimpleFragmentsBuilder {
private final FieldMapper mapper; private final FieldMapper mapper;