Anomaly identified by the detector. Please review whether this anomaly corresponds to a misuse.
Finding:
13
In File:
org/apache/lucene/search/SortField.java
In Method:
detectFieldType(IndexReader, String)
Code with Finding:
class SortField {
/**
* Attempts to detect the given field type for an IndexReader.
* @deprecated
*/
static int detectFieldType(IndexReader reader, String fieldKey) throws IOException {
String field = StringHelper.intern(fieldKey);
TermEnum enumerator = reader.terms(new Term(field));
try {
Term term = enumerator.term();
if (term == null) {
throw new RuntimeException("no terms in field " + field + " - cannot determine sort type");
}
int ret = 0;
if (term.field() == field) {
String termtext = term.text().trim();
try {
Integer.parseInt (termtext);
ret = SortField.INT;
} catch (NumberFormatException nfe1) {
try {
Long.parseLong(termtext);
ret = SortField.LONG;
} catch (NumberFormatException nfe2) {
try {
Float.parseFloat (termtext);
ret = SortField.FLOAT;
} catch (NumberFormatException nfe3) {
ret = SortField.STRING;
}
}
}
} else {
throw new RuntimeException("field \"" + field + "\" does not appear to be indexed");
}
return ret;
} finally {
enumerator.close();
}
}
}