Examples of updateDocument()


Examples of org.apache.lucene.index.IndexWriter.updateDocument()

                if (threadRandom.nextDouble() <= addChance) {
                  String id = String.format(Locale.ROOT, "%d_%04x", threadID, threadRandom.nextInt(idCount));
                  Integer field = threadRandom.nextInt(Integer.MAX_VALUE);
                  doc.add(new StringField("id", id, Field.Store.YES));
                  doc.add(new IntField("field", field.intValue(), Field.Store.YES));
                  w.updateDocument(new Term("id", id), doc);
                  rt.add(id, field);
                  if (values.put(id, field) == null) {
                    allIDs.add(id);
                  }
                }
View Full Code Here

Examples of org.apache.lucene.index.IndexWriter.updateDocument()

    doc.add(new Field(field_name, "la la", type));
    doc.add(new Field(field_name, "foo bar foo bar foo", type));

    Directory dir = newDirectory();
    IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random(), TEST_VERSION_CURRENT, mockAnalyzer));
    writer.updateDocument(new Term("id", "1"), doc);
    writer.commit();
    writer.close();
    DirectoryReader reader = DirectoryReader.open(dir);

    //Index document in Memory index
View Full Code Here

Examples of org.apache.lucene.index.IndexWriter.updateDocument()

        assertThat(UidField.loadVersion(reader, new Term("_uid", "1")), equalTo(-2l));
        assertThat(UidField.loadDocIdAndVersion(reader, new Term("_uid", "1")).version, equalTo(-2l));

        doc = new Document();
        doc.add(new UidField("_uid", "1", 1));
        writer.updateDocument(new Term("_uid", "1"), doc);
        reader = reader.reopen();
        assertThat(UidField.loadVersion(reader, new Term("_uid", "1")), equalTo(1l));
        assertThat(UidField.loadDocIdAndVersion(reader, new Term("_uid", "1")).version, equalTo(1l));

        doc = new Document();
View Full Code Here

Examples of org.apache.lucene.index.IndexWriter.updateDocument()

        assertThat(UidField.loadDocIdAndVersion(reader, new Term("_uid", "1")).version, equalTo(1l));

        doc = new Document();
        UidField uid = new UidField("_uid", "1", 2);
        doc.add(uid);
        writer.updateDocument(new Term("_uid", "1"), doc);
        reader = reader.reopen();
        assertThat(UidField.loadVersion(reader, new Term("_uid", "1")), equalTo(2l));
        assertThat(UidField.loadDocIdAndVersion(reader, new Term("_uid", "1")).version, equalTo(2l));

        // test reuse of uid field
View Full Code Here

Examples of org.apache.lucene.index.IndexWriter.updateDocument()

        // test reuse of uid field
        doc = new Document();
        uid.version(3);
        doc.add(uid);
        writer.updateDocument(new Term("_uid", "1"), doc);
        reader = reader.reopen();
        assertThat(UidField.loadVersion(reader, new Term("_uid", "1")), equalTo(3l));
        assertThat(UidField.loadDocIdAndVersion(reader, new Term("_uid", "1")).version, equalTo(3l));

        writer.deleteDocuments(new Term("_uid", "1"));
View Full Code Here

Examples of org.apache.lucene.index.IndexWriter.updateDocument()

    doc.add(new Field(field_name, "la la", type));
    doc.add(new Field(field_name, "foo bar foo bar foo", type));

    Directory dir = newDirectory();
    IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random(), TEST_VERSION_CURRENT, mockAnalyzer));
    writer.updateDocument(new Term("id", "1"), doc);
    writer.commit();
    writer.close();
    DirectoryReader reader = DirectoryReader.open(dir);

    //Index document in Memory index
View Full Code Here

Examples of org.apache.lucene.index.IndexWriter.updateDocument()

  public void index(T item) throws CorruptIndexException, IOException, ItemException {
    IndexPathProperty pathIndex = new IndexPathProperty();
    FSDirectory directory = FSDirectory.open(new File(pathIndex.getValue()));
    IndexWriter writer = new IndexWriter(directory, new StandardAnalyzer(Version.LUCENE_30), IndexWriter.MaxFieldLength.LIMITED);

    writer.updateDocument(new Term(type + "_id", item.getId().toString()), item.getDocument());
    writer.optimize();
    writer.close();
    directory.close();
  }
 
View Full Code Here

Examples of org.apache.lucene.index.IndexWriter.updateDocument()

  public static List<Tag> extractTag(List<? extends Indexable> list) throws CorruptIndexException, LockObtainFailedException, IOException, ItemException {
    RAMDirectory directory = new RAMDirectory();
    IndexWriter writer = new IndexWriter(directory, new StandardAnalyzer(Version.LUCENE_30), IndexWriter.MaxFieldLength.LIMITED);

    for (Indexable item : list) {
      writer.updateDocument(item.getTerm(),item.getDocument());
    }
   
    writer.optimize();
    writer.close();
   
View Full Code Here

Examples of org.apache.lucene.index.IndexWriter.updateDocument()

    final IndexWriterConfig config = new IndexWriterConfig(
        ConstResolver.VERSION, analyzer);

    final IndexWriter writer = new IndexWriter(getDirectory(), config);

    writer.updateDocument(Status.TERM, doc);

    writer.close();

  }
View Full Code Here

Examples of org.apache.lucene.index.IndexWriter.updateDocument()

 
  public void index(T item) throws CorruptIndexException, IOException, ItemException {
    FSDirectory directory = FSDirectory.open(new File(Application.getApplication().getNoteIndexPath()));
    IndexWriter writer = new IndexWriter(directory, new StandardAnalyzer(Version.LUCENE_30), IndexWriter.MaxFieldLength.LIMITED);

    writer.updateDocument(new Term(type + "_id", item.getId().toString()), item.getDocument());
    writer.optimize();
    writer.close();
    directory.close();
  }
 
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.