Package org.apache.lucene.index

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


        hdr.add( new Field( FLD_IDXINFO, VERSION + ArtifactInfo.FS + getRepositoryId(), Field.Store.YES, Field.Index.NO ) );

        IndexWriter w = getIndexWriter();

        w.updateDocument( DESCRIPTOR_TERM, hdr );

        w.commit();
    }

    private void deleteIndexFiles( boolean full )
View Full Code Here


    protected void setGroups( Collection<String> groups, String groupField, String groupFieldValue,
                              String groupListField )
        throws IOException, CorruptIndexException
    {
        final IndexWriter w = getIndexWriter();
        w.updateDocument( new Term( groupField, groupFieldValue ),
            createGroupsDocument( groups, groupField, groupFieldValue, groupListField ) );
    }

    protected Document createGroupsDocument( Collection<String> groups, String field, String fieldValue,
                                             String listField )
View Full Code Here

                if ( !equals( d, old ) )
                {
                    IndexWriter w = context.getIndexWriter();

                    w.updateDocument( new Term( ArtifactInfo.UINFO, ac.getArtifactInfo().getUinfo() ), d );

                    updateGroups( context, ac );

                    context.updateTimestamp();
                }
View Full Code Here

                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

    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

        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

        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

        // 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

    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

  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

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.