use of org.apache.lucene.document.NumericField in project neo4j-mobile-android by neo4j-contrib.
the class IndexType method instantiateField.
Fieldable instantiateField(String key, Object value, Index analyzed) {
Fieldable field = null;
if (value instanceof Number) {
Number number = (Number) value;
NumericField numberField = new NumericField(key, Store.YES, true);
if (value instanceof Long) {
numberField.setLongValue(number.longValue());
} else if (value instanceof Float) {
numberField.setFloatValue(number.floatValue());
} else if (value instanceof Double) {
numberField.setDoubleValue(number.doubleValue());
} else {
numberField.setIntValue(number.intValue());
}
field = numberField;
} else {
field = new Field(key, value.toString(), Store.YES, analyzed);
}
return field;
}
use of org.apache.lucene.document.NumericField in project querydsl by querydsl.
the class LuceneQueryTest method createDocument.
private Document createDocument(final String docTitle, final String docAuthor, final String docText, final int docYear, final double docGross) {
final Document doc = new Document();
doc.add(new Field("title", docTitle, Store.YES, Index.ANALYZED));
doc.add(new Field("author", docAuthor, Store.YES, Index.ANALYZED));
doc.add(new Field("text", docText, Store.YES, Index.ANALYZED));
doc.add(new NumericField("year", Store.YES, true).setIntValue(docYear));
doc.add(new NumericField("gross", Store.YES, true).setDoubleValue(docGross));
return doc;
}
Aggregations