lucene4: fixed SimpleIndexQueryParserTests
This commit is contained in:
parent
db639e5c2e
commit
bf13f3f81e
|
@ -47,9 +47,10 @@ public class StringFieldMapper extends AbstractFieldMapper<String> implements Al
|
|||
public static final String CONTENT_TYPE = "string";
|
||||
|
||||
public static class Defaults extends AbstractFieldMapper.Defaults {
|
||||
public static final FieldType STRING_FIELD_TYPE = new FieldType(NumberFieldMapper.Defaults.NUMBER_FIELD_TYPE);
|
||||
public static final FieldType STRING_FIELD_TYPE = new FieldType(AbstractFieldMapper.Defaults.FIELD_TYPE);
|
||||
|
||||
static {
|
||||
STRING_FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_ONLY);
|
||||
STRING_FIELD_TYPE.freeze();
|
||||
}
|
||||
|
||||
|
|
|
@ -180,32 +180,32 @@ public class MatchQuery {
|
|||
}
|
||||
|
||||
// Logic similar to QueryParser#getFieldQuery
|
||||
final TokenStream source;
|
||||
TokenStream source = null;
|
||||
CachingTokenFilter buffer = null;
|
||||
CharTermAttribute termAtt = null;
|
||||
PositionIncrementAttribute posIncrAtt = null;
|
||||
boolean success = false;
|
||||
try {
|
||||
source = analyzer.tokenStream(field, new FastStringReader(text));
|
||||
source.reset();
|
||||
success = true;
|
||||
} catch(IOException ex) {
|
||||
//LUCENE 4 UPGRADE not sure what todo here really lucene 3.6 had a tokenStream that didn't throw an exc.
|
||||
throw new ElasticSearchParseException("failed to process query", ex);
|
||||
// success==false if we hit an exception
|
||||
}
|
||||
CachingTokenFilter buffer = new CachingTokenFilter(source);
|
||||
CharTermAttribute termAtt = null;
|
||||
PositionIncrementAttribute posIncrAtt = null;
|
||||
int numTokens = 0;
|
||||
int positionCount = 0;
|
||||
boolean severalTokensAtSamePosition = false;
|
||||
|
||||
boolean success = false;
|
||||
buffer.reset();
|
||||
if (success) {
|
||||
buffer = new CachingTokenFilter(source);
|
||||
buffer.reset();
|
||||
if (buffer.hasAttribute(CharTermAttribute.class)) {
|
||||
termAtt = buffer.getAttribute(CharTermAttribute.class);
|
||||
}
|
||||
if (buffer.hasAttribute(PositionIncrementAttribute.class)) {
|
||||
posIncrAtt = buffer.getAttribute(PositionIncrementAttribute.class);
|
||||
}
|
||||
}
|
||||
|
||||
int positionCount = 0;
|
||||
boolean severalTokensAtSamePosition = false;
|
||||
|
||||
boolean hasMoreTokens = false;
|
||||
if (termAtt != null) {
|
||||
|
@ -225,12 +225,14 @@ public class MatchQuery {
|
|||
// ignore
|
||||
}
|
||||
}
|
||||
try {
|
||||
// rewind the buffer stream
|
||||
buffer.reset();
|
||||
|
||||
}
|
||||
try {
|
||||
// close original stream - all tokens buffered
|
||||
if (source != null) {
|
||||
source.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// ignore
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ public class SimpleIndexQueryParserTests {
|
|||
|
||||
private BytesRef longToPrefixCoded(long val) {
|
||||
BytesRef bytesRef = new BytesRef();
|
||||
NumericUtils.longToPrefixCoded(val, 0, bytesRef);
|
||||
NumericUtils.longToPrefixCoded(val, NumericUtils.PRECISION_STEP_DEFAULT, bytesRef);
|
||||
return bytesRef;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue