Package org.apache.lucene.document

Examples of org.apache.lucene.document.FieldType.freeze()


    FieldType type = new FieldType(TextField.TYPE_STORED);
    type.setStoreTermVectorOffsets(true);
    type.setStoreTermVectorPayloads(false);
    type.setStoreTermVectorPositions(true);
    type.setStoreTermVectors(true);
    type.freeze();

    Document doc = new Document();
    doc.add(new Field(field_name, "la la", type));
    doc.add(new Field(field_name, "foo bar foo bar foo", type));
View Full Code Here


      }
      FieldType ft = new FieldType();
      ft.setIndexOptions(opts);
      ft.setIndexed(true);
      ft.setOmitNorms(true);
      ft.freeze();
      final int numFields = random().nextInt(5);
      for (int j = 0; j < numFields; ++j) {
        doc.add(new Field("f_" + opts, TestUtil.randomSimpleString(random(), 2), ft));
      }
    }
View Full Code Here

    iwConf.setMaxBufferedDocs(RandomInts.randomIntBetween(random(), 2, 30));
    RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwConf);
   
    FieldType ft = new FieldType();
    ft.setStored(true);
    ft.freeze();

    final String string = TestUtil.randomSimpleString(random(), 50);
    final byte[] bytes = string.getBytes(StandardCharsets.UTF_8);
    final long l = random().nextBoolean() ? random().nextInt(42) : random().nextLong();
    final int i = random().nextBoolean() ? random().nextInt(42) : random().nextInt();
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);
View Full Code Here

      if (VERBOSE) {
        System.out.println("NOTE: LuceneTestCase: upgrade name=" + name + " type=" + newType);
      }
    }
    newType.freeze();
    fieldToType.put(name, newType);

    // TODO: we need to do this, but smarter, ie, most of
    // the time we set the same value for a given field but
    // sometimes (rarely) we change it up:
View Full Code Here

    FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);
    // TODO: if only we had IndexOptions.TERMS_ONLY...
    ft.setIndexOptions(IndexOptions.DOCS_AND_FREQS);
    ft.setOmitNorms(true);
    ft.freeze();

    Document doc = new Document();
    Field field = new Field("body", "", ft);
    doc.add(field);
View Full Code Here

            customType.setStoreTermVectors(true);
            customType.setStoreTermVectorOffsets(true);
            break;
          }
          FieldType newType = new FieldType(customType);
          newType.freeze();
          tvTypes.put(fieldName, newType);
        }
       
        switch (nextInt(4)) {
          case 0:
View Full Code Here

    Document doc = new Document();
    iw.addDocument(doc);
    FieldType ft = new FieldType(StoredField.TYPE);
    ft.setStoreTermVectors(true);
    ft.freeze();
    doc.add(new Field("field", "value", ft));
    try {
      iw.addDocument(doc);
      fail("should have hit exc");
    } catch (IllegalArgumentException iae) {
View Full Code Here

    @Override
    public IndexableFieldType fieldType() {
      FieldType ft = new FieldType(StoredField.TYPE);
      ft.setStoreTermVectors(true);
      ft.freeze();
      return ft;
    }
  }

  // LUCENE-5611
View Full Code Here

                                 new MockAnalyzer(random())));
    try {
      final FieldType ft = new FieldType();
      ft.setIndexed(true);
      ft.setStored(random().nextBoolean());
      ft.freeze();
     
      final Document doc = new Document();
      if (random().nextBoolean()) {
        // totally ok short field value
        doc.add(new Field(TestUtil.randomSimpleString(random(), 1, 10),
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.