Search in sources :

Example 1 with DoubleField

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);
    }
}
Also used : StringField(org.apache.lucene.document.StringField) Document(org.apache.lucene.document.Document) DoubleField(org.apache.lucene.document.DoubleField)

Example 2 with DoubleField

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;
}
Also used : NumericDocValuesField(org.apache.lucene.document.NumericDocValuesField) DoubleDocValuesField(org.apache.lucene.document.DoubleDocValuesField) SortedDocValuesField(org.apache.lucene.document.SortedDocValuesField) TextField(org.apache.lucene.document.TextField) IntField(org.apache.lucene.document.IntField) Document(org.apache.lucene.document.Document) BytesRef(org.apache.lucene.util.BytesRef) DoubleField(org.apache.lucene.document.DoubleField)

Example 3 with DoubleField

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;
}
Also used : LongField(org.apache.lucene.document.LongField) FloatField(org.apache.lucene.document.FloatField) DoubleField(org.apache.lucene.document.DoubleField) Field(org.apache.lucene.document.Field) IntField(org.apache.lucene.document.IntField) LongField(org.apache.lucene.document.LongField) StringReader(java.io.StringReader) IntField(org.apache.lucene.document.IntField) Document(org.apache.lucene.document.Document) DoubleField(org.apache.lucene.document.DoubleField) FloatField(org.apache.lucene.document.FloatField)

Example 4 with DoubleField

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;
}
Also used : FieldFactory.newFulltextField(org.apache.jackrabbit.oak.plugins.index.lucene.FieldFactory.newFulltextField) LongField(org.apache.lucene.document.LongField) StringField(org.apache.lucene.document.StringField) SortedSetDocValuesFacetField(org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetField) FieldFactory.newDepthField(org.apache.jackrabbit.oak.plugins.index.lucene.FieldFactory.newDepthField) FieldFactory.newPropertyField(org.apache.jackrabbit.oak.plugins.index.lucene.FieldFactory.newPropertyField) DoubleDocValuesField(org.apache.lucene.document.DoubleDocValuesField) FieldFactory.newPathField(org.apache.jackrabbit.oak.plugins.index.lucene.FieldFactory.newPathField) NumericDocValuesField(org.apache.lucene.document.NumericDocValuesField) DoubleField(org.apache.lucene.document.DoubleField) SortedDocValuesField(org.apache.lucene.document.SortedDocValuesField) FieldFactory.newAncestorsField(org.apache.jackrabbit.oak.plugins.index.lucene.FieldFactory.newAncestorsField) Field(org.apache.lucene.document.Field) LongField(org.apache.lucene.document.LongField) StringField(org.apache.lucene.document.StringField) DoubleField(org.apache.lucene.document.DoubleField)

Aggregations

DoubleField (org.apache.lucene.document.DoubleField)4 Document (org.apache.lucene.document.Document)3 DoubleDocValuesField (org.apache.lucene.document.DoubleDocValuesField)2 Field (org.apache.lucene.document.Field)2 IntField (org.apache.lucene.document.IntField)2 LongField (org.apache.lucene.document.LongField)2 NumericDocValuesField (org.apache.lucene.document.NumericDocValuesField)2 SortedDocValuesField (org.apache.lucene.document.SortedDocValuesField)2 StringField (org.apache.lucene.document.StringField)2 StringReader (java.io.StringReader)1 FieldFactory.newAncestorsField (org.apache.jackrabbit.oak.plugins.index.lucene.FieldFactory.newAncestorsField)1 FieldFactory.newDepthField (org.apache.jackrabbit.oak.plugins.index.lucene.FieldFactory.newDepthField)1 FieldFactory.newFulltextField (org.apache.jackrabbit.oak.plugins.index.lucene.FieldFactory.newFulltextField)1 FieldFactory.newPathField (org.apache.jackrabbit.oak.plugins.index.lucene.FieldFactory.newPathField)1 FieldFactory.newPropertyField (org.apache.jackrabbit.oak.plugins.index.lucene.FieldFactory.newPropertyField)1 FloatField (org.apache.lucene.document.FloatField)1 TextField (org.apache.lucene.document.TextField)1 SortedSetDocValuesFacetField (org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetField)1 BytesRef (org.apache.lucene.util.BytesRef)1