Fixed unreported bug when doing Lucene search across all attributes on types that contain numeric properties

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3123 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-06-16 10:46:04 +00:00
parent 43a69ac371
commit dab54834b8
4 changed files with 49 additions and 20 deletions

View File

@@ -49,11 +49,18 @@ public class DoubleTokenFilter extends Tokenizer
Token candidate; Token candidate;
while((candidate = baseTokeniser.next()) != null) while((candidate = baseTokeniser.next()) != null)
{ {
Double d = Double.valueOf(candidate.termText()); try
String valueString = NumericEncoder.encode(d.doubleValue()); {
Token doubleToken = new Token(valueString, candidate.startOffset(), candidate.startOffset(), Double d = Double.valueOf(candidate.termText());
candidate.type()); String valueString = NumericEncoder.encode(d.doubleValue());
return doubleToken; Token doubleToken = new Token(valueString, candidate.startOffset(), candidate.startOffset(),
candidate.type());
return doubleToken;
}
catch (NumberFormatException e)
{
// just ignore and try the next one
}
} }
return null; return null;
} }

View File

@@ -49,11 +49,18 @@ public class FloatTokenFilter extends Tokenizer
Token candidate; Token candidate;
while((candidate = baseTokeniser.next()) != null) while((candidate = baseTokeniser.next()) != null)
{ {
Float floatValue = Float.valueOf(candidate.termText()); try
String valueString = NumericEncoder.encode(floatValue.floatValue()); {
Token floatToken = new Token(valueString, candidate.startOffset(), candidate.startOffset(), Float floatValue = Float.valueOf(candidate.termText());
candidate.type()); String valueString = NumericEncoder.encode(floatValue.floatValue());
return floatToken; Token floatToken = new Token(valueString, candidate.startOffset(), candidate.startOffset(),
candidate.type());
return floatToken;
}
catch (NumberFormatException e)
{
// just ignore and try the next one
}
} }
return null; return null;
} }

View File

@@ -49,11 +49,18 @@ public class IntegerTokenFilter extends Tokenizer
Token candidate; Token candidate;
while((candidate = baseTokeniser.next()) != null) while((candidate = baseTokeniser.next()) != null)
{ {
Integer integer = Integer.valueOf(candidate.termText()); try
String valueString = NumericEncoder.encode(integer.intValue()); {
Token integerToken = new Token(valueString, candidate.startOffset(), candidate.startOffset(), Integer integer = Integer.valueOf(candidate.termText());
candidate.type()); String valueString = NumericEncoder.encode(integer.intValue());
return integerToken; Token integerToken = new Token(valueString, candidate.startOffset(), candidate.startOffset(),
candidate.type());
return integerToken;
}
catch (NumberFormatException e)
{
// just ignore and try the next one
}
} }
return null; return null;
} }

View File

@@ -19,6 +19,7 @@ package org.alfresco.repo.search.impl.lucene.analysis;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
import org.alfresco.error.AlfrescoRuntimeException;
import org.apache.lucene.analysis.Token; import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.standard.StandardTokenizer; import org.apache.lucene.analysis.standard.StandardTokenizer;
@@ -49,11 +50,18 @@ public class LongTokenFilter extends Tokenizer
Token candidate; Token candidate;
while((candidate = baseTokeniser.next()) != null) while((candidate = baseTokeniser.next()) != null)
{ {
Long longValue = Long.valueOf(candidate.termText()); try
String valueString = NumericEncoder.encode(longValue.longValue()); {
Token longToken = new Token(valueString, candidate.startOffset(), candidate.startOffset(), Long longValue = Long.valueOf(candidate.termText());
candidate.type()); String valueString = NumericEncoder.encode(longValue.longValue());
return longToken; Token longToken = new Token(valueString, candidate.startOffset(), candidate.startOffset(),
candidate.type());
return longToken;
}
catch (NumberFormatException e)
{
// just ignore and try the next one
}
} }
return null; return null;
} }