Package org.apache.lucene.document

Examples of org.apache.lucene.document.IntField


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


    IndexWriter indexWriter = new IndexWriter(directory, new IndexWriterConfig(LUCENE_VERSION, new KeywordAnalyzer()));
    for (int i = 0; i < length; i++) {
      Document document = new Document();
      document.add(new StringField("f1", "value", Store.NO));
      document.add(new IntDocValuesField("index", i));
      document.add(new IntField("index", i, Store.YES));
      indexWriter.addDocument(document);
    }
    indexWriter.close();
    return DirectoryReader.open(directory);
  }
View Full Code Here

    }
  }

  private Document getDoc(int i) {
    Document document = new Document();
    document.add(new IntField("id", i, Store.YES));
    return document;
  }
View Full Code Here

    indexWriter.close();
  }

  private static Document getDoc(int i) {
    Document document = new Document();
    document.add(new IntField("id", i, Store.YES));
    return document;
  }
View Full Code Here

    unstoredInt4.setNumericPrecisionStep(4);

    final FieldType unstoredInt2 = new FieldType(unstoredInt);
    unstoredInt2.setNumericPrecisionStep(2);

    IntField
      field8 = new IntField("field8", 0, storedInt8),
      field4 = new IntField("field4", 0, storedInt4),
      field2 = new IntField("field2", 0, storedInt2),
      fieldNoTrie = new IntField("field"+Integer.MAX_VALUE, 0, storedIntNone),
      ascfield8 = new IntField("ascfield8", 0, unstoredInt8),
      ascfield4 = new IntField("ascfield4", 0, unstoredInt4),
      ascfield2 = new IntField("ascfield2", 0, unstoredInt2);
   
    Document doc = new Document();
    // add fields, that have a distance to test general functionality
    doc.add(field8); doc.add(field4); doc.add(field2); doc.add(fieldNoTrie);
    // add ascending fields with a distance of 1, beginning at -noDocs/2 to test the correct splitting of range and inclusive/exclusive
    doc.add(ascfield8); doc.add(ascfield4); doc.add(ascfield2);
   
    // Add a series of noDocs docs with increasing int values
    for (int l=0; l<noDocs; l++) {
      int val=distance*l+startOffset;
      field8.setIntValue(val);
      field4.setIntValue(val);
      field2.setIntValue(val);
      fieldNoTrie.setIntValue(val);

      val=l-(noDocs/2);
      ascfield8.setIntValue(val);
      ascfield4.setIntValue(val);
      ascfield2.setIntValue(val);
      writer.addDocument(doc);
    }
 
    reader = writer.getReader();
    searcher=newSearcher(reader);
View Full Code Here

      } else {
        // int/long
        if (random().nextBoolean()) {
          final int i = random().nextInt();
          answer = Integer.valueOf(i);
          nf = new IntField("nf", i, Field.Store.NO);
          sf = new StoredField("nf", i);
          typeAnswer = NumericType.INT;
        } else {
          final long l = random().nextLong();
          answer = Long.valueOf(l);
          nf = new LongField("nf", l, Field.Store.NO);
          sf = new StoredField("nf", l);
          typeAnswer = NumericType.LONG;
        }
      }
      doc.add(nf);
      doc.add(sf);
      answers[id] = answer;
      typeAnswers[id] = typeAnswer;
      FieldType ft = new FieldType(IntField.TYPE_NOT_STORED);
      ft.setNumericPrecisionStep(Integer.MAX_VALUE);
      doc.add(new IntField("id", id, ft));
      w.addDocument(doc);
    }
    final DirectoryReader r = w.getReader();
    w.close();
   
View Full Code Here

    doc.add(new Field("autf8", "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", customType2));
    doc.add(new Field("utf8", "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", customType2));
    doc.add(new Field("content2", "here is more content with aaa aaa aaa", customType2));
    doc.add(new Field("fie\u2C77ld", "field with non-ascii name", customType2));
    // add numeric fields, to test if flex preserves encoding
    doc.add(new IntField("trieInt", id, Field.Store.NO));
    doc.add(new LongField("trieLong", (long) id, Field.Store.NO));
    // add docvalues fields
    doc.add(new NumericDocValuesField("dvByte", (byte) id));
    byte bytes[] = new byte[] {
      (byte)(id >>> 24), (byte)(id >>> 16),(byte)(id >>> 8),(byte)id
View Full Code Here

    }

    final FieldType type = new FieldType(StringField.TYPE_STORED);
    type.setIndexed(false);
    type.freeze();
    IntField id = new IntField("id", 0, Store.YES);
    for (int i = 0; i < data.length; ++i) {
      Document doc = new Document();
      doc.add(id);
      id.setIntValue(i);
      for (int j = 0; j < data[i].length; ++j) {
        Field f = new Field("bytes" + j, data[i][j], type);
        doc.add(f);
      }
      iw.w.addDocument(doc);
View Full Code Here

    List<Field> fields = Arrays.asList(
        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) {
View Full Code Here

    iwConf.setMergePolicy(newLogMergePolicy(false));
    iw.close();
    iw = new RandomIndexWriter(random(), dir, iwConf);

    final Document validDoc = new Document();
    validDoc.add(new IntField("id", 0, Store.YES));
    iw.addDocument(validDoc);
    iw.commit();
   
    // make sure that #writeField will fail to trigger an abort
    final Document invalidDoc = new Document();
View Full Code Here

TOP

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

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.