private DocWithId() { idField = new StringField( NODE_ID_KEY, "", YES ); idValueField = new NumericDocValuesField( NODE_ID_KEY, 0L ); document = new Document(); document.add( idField ); document.add( idValueField ); }
private void addPatterns(String id, Map<Integer, Set<E>> p, boolean commit) { try{ setIndexWriter(); Document doc = new Document(); doc.add(new StringField("sentid", id, Field.Store.YES)); doc.add(new Field("patterns", getBytes(p), LuceneFieldType.NOT_INDEXED)); indexWriter.addDocument(doc); if(commit){ indexWriter.commit(); //closeIndexWriter(); } }catch(IOException e){ throw new RuntimeException(e); } }
private static void writeSomething( IndexReference indexReference ) throws IOException { IndexWriter writer = indexReference.getWriter(); writer.addDocument( new Document() ); writer.commit(); }
private Document makeDocument(TxnHeader header, EntryTypes type, AtomicInteger count, AtomicLong from, AtomicLong to) { count.incrementAndGet(); if ( header.getTime() < from.get() ) { from.set(header.getTime()); } if ( header.getTime() > to.get() ) { to.set(header.getTime()); } NumericField dateField = new NumericField(FieldNames.DATE, Field.Store.YES, true); dateField.setLongValue(header.getTime()); Document document = new Document(); document.add(new Field(FieldNames.TYPE, Integer.toString(type.getId()), Field.Store.YES, Field.Index.NOT_ANALYZED)); document.add(dateField); return document; } }
Document doc = new Document(); doc.add(field); if (writer.getConfig().getOpenMode() == OpenMode.CREATE) { writer.addDocument(doc); } else { writer.updateDocument(new Term("content",strs[i]), doc);
@Override protected void add(List<CoreLabel> tokens, String sentid, boolean addProcessedText){ try{ setIndexWriter(); Document doc = new Document(); for(CoreLabel l : tokens) { for (Map.Entry<String, String> en: transformCoreLabeltoString.apply(l).entrySet()) { doc.add(new StringField(en.getKey(), en.getValue(), Field.Store.YES));//, ANALYZED)); } if(addProcessedText){ String ptxt = l.get(PatternsAnnotations.ProcessedTextAnnotation.class); if(!stopWords.contains(ptxt.toLowerCase())) doc.add(new StringField(Token.getKeyForClass(PatternsAnnotations.ProcessedTextAnnotation.class), ptxt, Field.Store.YES));//, ANALYZED)); } } doc.add(new StringField("sentid", sentid, Field.Store.YES)); if(tokens!= null && saveTokens) doc.add(new Field("tokens", getProtoBufAnnotation(tokens), LuceneFieldType.NOT_INDEXED)); indexWriter.addDocument(doc); }catch(IOException e){ throw new RuntimeException(e); } }
private DocWithId() { idField = new StringField( FIELD_ENTITY_ID, "", YES ); idValueField = new NumericDocValuesField( FIELD_ENTITY_ID, 0L ); document = new Document(); document.add( idField ); document.add( idValueField ); }
final Document doc = new Document(); final Field v = new TextField(Fields.VENDOR, Fields.VENDOR, Field.Store.YES); final Field p = new TextField(Fields.PRODUCT, Fields.PRODUCT, Field.Store.YES); doc.add(v); doc.add(p); v.setStringValue(pair.getLeft()); p.setStringValue(pair.getRight()); indexWriter.addDocument(doc); productFieldAnalyzer.reset(); vendorFieldAnalyzer.reset();
fa.setFoldingEnabled(RuntimeEnvironment.getInstance().isFoldingEnabled()); Document doc = new Document(); try (Writer xrefOut = newXrefWriter(fa, path)) { analyzerGuru.populateDocument(doc, file, path, fa, xrefOut); writer.addDocument(doc); } catch (Throwable t) { cleanupResources(doc);
private void addCluster(IndexWriter iwriter, StopCluster stopCluster) throws IOException { Document doc = new Document(); doc.add(new TextField("name", stopCluster.name, Field.Store.YES)); doc.add(new DoubleField("lat", stopCluster.lat, Field.Store.YES)); doc.add(new DoubleField("lon", stopCluster.lon, Field.Store.YES)); doc.add(new StringField("id", stopCluster.id, Field.Store.YES)); doc.add(new StringField("category", Category.CLUSTER.name(), Field.Store.YES)); iwriter.addDocument(doc); }
public static Document newBaseDocument( long entityId ) { Document doc = new Document(); doc.add( new StringField( LuceneExplicitIndex.KEY_DOC_ID, "" + entityId, Store.YES ) ); doc.add( new NumericDocValuesField( LuceneExplicitIndex.KEY_DOC_ID, entityId ) ); return doc; }
public void indexDocument(File file) throws Exception { Document document = new Document(); document.add(new TextField("filename", file.getName(), Store.YES)); document.add(new TextField("fulltext", tika.parseToString(file), Store.NO)); writer.addDocument(document); } }
public Document convert(final ProvenanceEventRecord record, final StorageSummary persistedEvent) { final Document doc = new Document(); addField(doc, SearchableFields.FlowFileUUID, record.getFlowFileUuid()); addField(doc, SearchableFields.Filename, record.getAttribute(CoreAttributes.FILENAME.key())); doc.add(new LongField(SearchableFields.LineageStartDate.getSearchableFieldName(), record.getLineageStartDate(), Store.NO)); doc.add(new LongField(SearchableFields.EventTime.getSearchableFieldName(), record.getEventTime(), Store.NO)); doc.add(new LongField(SearchableFields.FileSize.getSearchableFieldName(), record.getFileSize(), Store.NO));
@Test void createWritablePartition() throws Exception { try ( AbstractIndexPartition indexPartition = new WritableIndexPartitionFactory( IndexWriterConfigs::standard ) .createPartition( testDirectory.directory(), directory ) ) { try ( IndexWriter indexWriter = indexPartition.getIndexWriter() ) { indexWriter.addDocument( new Document() ); indexWriter.commit(); indexPartition.maybeRefreshBlocking(); try ( PartitionSearcher searcher = indexPartition.acquireSearcher() ) { assertEquals( 1, searcher.getIndexSearcher().getIndexReader().numDocs(), "We should be able to see newly added document " ); } } } }
private static void insertRandomDocuments( IndexWriter writer ) throws IOException { Document doc = new Document(); doc.add( new StringField( "a", "b", Field.Store.YES ) ); doc.add( new StringField( "c", "d", Field.Store.NO ) ); writer.addDocument( doc ); writer.commit(); }
private static Document newDocument() { Document doc = new Document(); doc.add( new StringField( "test", UUID.randomUUID().toString(), Field.Store.YES ) ); return doc; } }