Package org.apache.lucene.document

Examples of org.apache.lucene.document.DoubleField


        break;
      case LONG:
        field = new LongField(type.name(), 0l, ft);
        break;
      case DOUBLE:
        field = new DoubleField(type.name(), 0.0, ft);
        break;
      default:
        fail();
        field = null;
      }
View Full Code Here


      fields.add(newStringField("short", "" + ((short) random().nextInt()), Field.Store.NO));
      fields.add(new IntField("int", random().nextInt(), Field.Store.NO));
      fields.add(new LongField("long", random().nextLong(), Field.Store.NO));

      fields.add(new FloatField("float", random().nextFloat(), Field.Store.NO));
      fields.add(new DoubleField("double", random().nextDouble(), Field.Store.NO));
      fields.add(newStringField("bytes", _TestUtil.randomRealisticUnicodeString(random()), Field.Store.NO));
      fields.add(newStringField("bytesval", _TestUtil.randomRealisticUnicodeString(random()), Field.Store.NO));
      fields.add(new DoubleField("double", random().nextDouble(), Field.Store.NO));

      if (supportsDocValues) {
        fields.add(new NumericDocValuesField("intdocvalues", random().nextInt()));
        fields.add(new FloatDocValuesField("floatdocvalues", random().nextFloat()));
        fields.add(new SortedDocValuesField("sortedbytesdocvalues", new BytesRef(_TestUtil.randomRealisticUnicodeString(random()))));
View Full Code Here

    // TODO: we could index in radians instead ... saves all the conversions in getBoundingBoxFilter

    // Add documents with latitude/longitude location:
    Document doc = new Document();
    doc.add(new DoubleField("latitude", 40.759011, Field.Store.NO));
    doc.add(new DoubleField("longitude", -73.9844722, Field.Store.NO));
    writer.addDocument(doc);
   
    doc = new Document();
    doc.add(new DoubleField("latitude", 40.718266, Field.Store.NO));
    doc.add(new DoubleField("longitude", -74.007819, Field.Store.NO));
    writer.addDocument(doc);
   
    doc = new Document();
    doc.add(new DoubleField("latitude", 40.7051157, Field.Store.NO));
    doc.add(new DoubleField("longitude", -74.0088305, Field.Store.NO));
    writer.addDocument(doc);

    // Open near-real-time searcher
    searcher = new IndexSearcher(DirectoryReader.open(writer, true));
    writer.close();
View Full Code Here

    for(int i=0;i<numDocs;i++) {
      Document doc = new Document();
      double v = random().nextDouble();
      values[i] = v;
      doc.add(new DoubleDocValuesField("field", v));
      doc.add(new DoubleField("field", v, Field.Store.NO));
      w.addDocument(doc);
      minValue = Math.min(minValue, v);
      maxValue = Math.max(maxValue, v);
    }
    IndexReader r = w.getReader();
View Full Code Here

    getLuceneDocument().add( numField );
  }

  @Override
  public void addDoubleNumericField(double value, String name, int precisionStep, SerializableStore store, boolean indexed, float boost, boolean omitNorms, boolean omitTermFreqAndPositions) {
    final DoubleField numField = new DoubleField( name, value, getStore( store ) );
    numField.setBoost( boost );
    getLuceneDocument().add( numField );
  }
View Full Code Here

  @Override
  public Iterable<? extends Field> getFieldsForColumn(String family, Column column) {
    String name = getName(family, column.getName());
    double value = Double.parseDouble(column.getValue());
    DoubleField field = new DoubleField(name, value, _typeStored);
    if (isSortEnable()) {
      return addSort(name, Double.doubleToRawLongBits(value), field);
    }
    return makeIterable(field);
  }
View Full Code Here

  @Override
  public Iterable<? extends Field> getFieldsForSubColumn(String family, Column column, String subName) {
    String name = getName(family, column.getName(), subName);
    double value = Double.parseDouble(column.getValue());
    DoubleField field = new DoubleField(name, value, _typeNotStored);
    if (isSortEnable()) {
      return addSort(name, Double.doubleToRawLongBits(value), field);
    }
    return makeIterable(field);
  }
View Full Code Here

          sf = new StoredField("nf", f);
          typeAnswer = NumericType.FLOAT;
        } else {
          final double d = random().nextDouble();
          answer = Double.valueOf(d);
          nf = new DoubleField("nf", d, Field.Store.NO);
          sf = new StoredField("nf", d);
          typeAnswer = NumericType.DOUBLE;
        }
      } else {
        // int/long
View Full Code Here

        new Field("bytes", bytes, ft),
        new Field("string", string, ft),
        new LongField("long", l, Store.YES),
        new IntField("int", i, Store.YES),
        new FloatField("float", f, Store.YES),
        new DoubleField("double", d, Store.YES)
    );

    for (int k = 0; k < 100; ++k) {
      Document doc = new Document();
      for (Field fld : fields) {
View Full Code Here

  public void testInfiniteValues() throws Exception {
    Directory dir = newDirectory();
    RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
      newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
    Document doc = new Document();
    doc.add(new DoubleField("double", Double.NEGATIVE_INFINITY, Field.Store.NO));
    doc.add(new LongField("long", Long.MIN_VALUE, Field.Store.NO));
    writer.addDocument(doc);
   
    doc = new Document();
    doc.add(new DoubleField("double", Double.POSITIVE_INFINITY, Field.Store.NO));
    doc.add(new LongField("long", Long.MAX_VALUE, Field.Store.NO));
    writer.addDocument(doc);
   
    doc = new Document();
    doc.add(new DoubleField("double", 0.0, Field.Store.NO));
    doc.add(new LongField("long", 0L, Field.Store.NO));
    writer.addDocument(doc);
   
    for (double d : TestNumericUtils.DOUBLE_NANs) {
      doc = new Document();
      doc.add(new DoubleField("double", d, Field.Store.NO));
      writer.addDocument(doc);
    }
   
    writer.close();
   
View Full Code Here

TOP

Related Classes of org.apache.lucene.document.DoubleField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.