use of org.apache.lucene.document.DoubleField in project crate by crate.
the class DoubleColumnReferenceTest method insertValues.
@Override
protected void insertValues(IndexWriter writer) throws Exception {
for (double d = 0.5; d < 10.0d; d++) {
Document doc = new Document();
doc.add(new StringField("_id", Double.toString(d), Field.Store.NO));
doc.add(new DoubleField(column, d, Field.Store.NO));
writer.addDocument(doc);
}
}
use of org.apache.lucene.document.DoubleField 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) {
Document doc = new Document();
// Reusing field for performance
if (titleField == null) {
titleField = new TextField("title", docTitle, Store.YES);
doc.add(titleField);
titleSortedField = new SortedDocValuesField("title", new BytesRef(docTitle));
doc.add(titleSortedField);
} else {
titleField.setStringValue(docTitle);
titleSortedField.setBytesValue(new BytesRef(docTitle));
doc.add(titleField);
doc.add(titleSortedField);
}
if (authorField == null) {
authorField = new TextField("author", docAuthor, Store.YES);
doc.add(authorField);
authorSortedField = new SortedDocValuesField("author", new BytesRef(docAuthor));
doc.add(authorSortedField);
} else {
authorField.setStringValue(docAuthor);
authorSortedField.setBytesValue(new BytesRef(docAuthor));
doc.add(authorField);
doc.add(authorSortedField);
}
if (textField == null) {
textField = new TextField("text", docText, Store.YES);
doc.add(textField);
textSortedField = new SortedDocValuesField("text", new BytesRef(docText));
doc.add(textSortedField);
} else {
textField.setStringValue(docText);
textSortedField.setBytesValue(new BytesRef(docText));
doc.add(textField);
doc.add(textSortedField);
}
if (yearField == null) {
yearField = new IntField("year", docYear, Store.YES);
doc.add(yearField);
yearSortedField = new NumericDocValuesField("year", docYear);
doc.add(yearSortedField);
} else {
yearField.setIntValue(docYear);
yearSortedField.setLongValue(docYear);
doc.add(yearField);
doc.add(yearSortedField);
}
if (grossField == null) {
grossField = new DoubleField("gross", docGross, Store.YES);
doc.add(grossField);
grossSortedField = new DoubleDocValuesField("gross", docGross);
doc.add(grossSortedField);
} else {
grossField.setDoubleValue(docGross);
grossSortedField.setDoubleValue(docGross);
doc.add(grossField);
doc.add(grossSortedField);
}
return doc;
}
use of org.apache.lucene.document.DoubleField in project querydsl by querydsl.
the class LuceneSerializerTest method createDocument.
private Document createDocument() {
Document doc = new Document();
doc.add(new Field("title", new StringReader("Jurassic Park")));
doc.add(new Field("author", new StringReader("Michael Crichton")));
doc.add(new Field("text", new StringReader("It's a UNIX system! I know this!")));
doc.add(new Field("rating", new StringReader("Good")));
doc.add(new Field("publisher", "", Store.YES, Index.ANALYZED));
doc.add(new IntField("year", 1990, Store.YES));
doc.add(new DoubleField("gross", 900.0, Store.YES));
doc.add(new LongField("longField", 1, Store.YES));
doc.add(new IntField("shortField", 1, Store.YES));
doc.add(new IntField("byteField", 1, Store.YES));
doc.add(new FloatField("floatField", 1, Store.YES));
return doc;
}
use of org.apache.lucene.document.DoubleField in project jackrabbit-oak by apache.
the class LuceneDocumentMaker method addTypedFields.
private boolean addTypedFields(List<Field> fields, PropertyState property, String pname) {
int tag = property.getType().tag();
boolean fieldAdded = false;
for (int i = 0; i < property.count(); i++) {
Field f;
if (tag == Type.LONG.tag()) {
f = new LongField(pname, property.getValue(Type.LONG, i), Field.Store.NO);
} else if (tag == Type.DATE.tag()) {
String date = property.getValue(Type.DATE, i);
f = new LongField(pname, FieldFactory.dateToLong(date), Field.Store.NO);
} else if (tag == Type.DOUBLE.tag()) {
f = new DoubleField(pname, property.getValue(Type.DOUBLE, i), Field.Store.NO);
} else if (tag == Type.BOOLEAN.tag()) {
f = new StringField(pname, property.getValue(Type.BOOLEAN, i).toString(), Field.Store.NO);
} else {
f = new StringField(pname, property.getValue(Type.STRING, i), Field.Store.NO);
}
fields.add(f);
fieldAdded = true;
}
return fieldAdded;
}
Aggregations