List of usage examples for org.apache.lucene.document Field setDoubleValue
public void setDoubleValue(double value)
From source file:com.bewsia.script.LuceneHandler.java
License:Open Source License
protected void write(SEntity entity, Document doc) { String schema = entity.getSchema(); if (schema == null) schema = ""; String[] fields = schema.split("\\|"); for (int i = 0; i < fields.length && i + 1 < fields.length; i += 2) { String kind = fields[i];//from w w w . j ava 2s . c o m String fname = fields[i + 1]; if (SEntity.STRING.equalsIgnoreCase(kind)) { Field field = new Field(fname, entity.getString(fname), Store.YES, Index.NOT_ANALYZED_NO_NORMS); doc.add(field); } else if (SEntity.DOUBLE.equalsIgnoreCase(kind)) { NumericField field = new NumericField(fname, Store.YES, true); field.setDoubleValue(entity.getDouble(fname)); doc.add(field); } else if (SEntity.FLOAT.equalsIgnoreCase(kind)) { NumericField field = new NumericField(fname, Store.YES, true); field.setFloatValue(entity.getFloat(fname)); doc.add(field); } else if (SEntity.INTEGER.equalsIgnoreCase(kind)) { NumericField field = new NumericField(fname, Store.YES, true); field.setIntValue(entity.getInteger(fname)); doc.add(field); } else if (SEntity.LONG.equalsIgnoreCase(kind)) { NumericField field = new NumericField(fname, Store.YES, true); field.setLongValue(entity.getLong(fname)); doc.add(field); } else if (SEntity.ANALYZED.equalsIgnoreCase(kind)) { Field field = new Field(fname, entity.getString(fname), Store.YES, Index.ANALYZED); doc.add(field); } } }
From source file:com.vmware.xenon.services.common.LuceneIndexDocumentHelper.java
License:Open Source License
private Field getAndSetStoredField(String name, Double value) { Field f = this.storedFields.computeIfAbsent(name, (k) -> { return new StoredField(name, value); });//from w w w. j av a 2 s . c o m f.setDoubleValue(value); return f; }
From source file:org.apache.solr.legacy.TestLegacyField.java
License:Apache License
public void testLegacyDoubleField() throws Exception { Field fields[] = new Field[] { new LegacyDoubleField("foo", 5d, Field.Store.NO), new LegacyDoubleField("foo", 5d, Field.Store.YES) }; for (Field field : fields) { trySetByteValue(field);//w w w. j a v a 2 s .c o m trySetBytesValue(field); trySetBytesRefValue(field); field.setDoubleValue(6d); // ok trySetIntValue(field); trySetFloatValue(field); trySetLongValue(field); trySetReaderValue(field); trySetShortValue(field); trySetStringValue(field); trySetTokenStreamValue(field); assertEquals(6d, field.numericValue().doubleValue(), 0.0d); } }
From source file:org.apache.solr.legacy.TestLegacyField.java
License:Apache License
private void trySetDoubleValue(Field f) { expectThrows(IllegalArgumentException.class, () -> { f.setDoubleValue(Double.MAX_VALUE); });/* ww w . ja v a 2 s . c o m*/ }
From source file:suonos.lucene.fields.IndexedField.java
License:Apache License
public void setValue(Field field, Object value) { if (javaType == String.class) { field.setStringValue((String) value); } else if (javaType == Double.class) { field.setDoubleValue((Double) value); } else if (javaType == Float.class) { field.setFloatValue((Float) value); } else if (javaType == Integer.class) { field.setIntValue((Integer) value); } else if (javaType == Long.class) { field.setLongValue((Long) value); } else if (javaType == Boolean.class) { field.setStringValue(getBoolValue(value)); } else if (javaType == Date.class) { field.setLongValue(((Date) value).getTime()); } else if (javaType == Byte[].class) { field.setBytesValue((byte[]) value); }//from w w w.j av a2s. c om throw Validate.notAllowed(""); }