@Override public void enhance( Document document ) { document.add( new StringField( LuceneExplicitIndex.KEY_START_NODE_ID, "" + startNode, Store.YES ) ); document.add( new StringField( LuceneExplicitIndex.KEY_END_NODE_ID, "" + endNode, Store.YES ) ); } }
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 ); }
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 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);
private void indexRecord(TxnHeader header, Record record, AtomicInteger count, AtomicLong from, AtomicLong to) throws IOException { if ( record instanceof CreateTxn ) { CreateTxn createTxn = (CreateTxn)record; EntryTypes type = createTxn.getEphemeral() ? EntryTypes.CREATE_EPHEMERAL: EntryTypes.CREATE_PERSISTENT; Document document = makeDocument(header, type, count, from, to); addPath(document, createTxn.getPath()); addData(document, createTxn.getData()); writer.addDocument(document); } else if ( record instanceof DeleteTxn ) { DeleteTxn deleteTxn = (DeleteTxn)record; Document document = makeDocument(header, EntryTypes.DELETE, count, from, to); addPath(document, deleteTxn.getPath()); writer.addDocument(document); } else if ( record instanceof SetDataTxn ) { SetDataTxn setDataTxn = (SetDataTxn)record; NumericField versionField = new NumericField(FieldNames.VERSION, Field.Store.YES, true); versionField.setIntValue(setDataTxn.getVersion()); Document document = makeDocument(header, EntryTypes.SET_DATA, count, from, to); addPath(document, setDataTxn.getPath()); addData(document, setDataTxn.getData()); document.add(versionField); writer.addDocument(document); } }
document.add( new StoredField( TX_STATE_KEY, TX_STATE_VALUE ) ); cachedDocuments.put( id, document ); add = true; document.add( new StringField( ORPHANS_KEY, ORPHANS_VALUE, Store.NO ) ); addOrphan( null ); document.add( new StringField( ORPHANS_KEY, key, Store.NO ) ); addOrphan( key ); writer.addDocument( document );
DateTools.Resolution.MILLISECOND); path = Util.fixPathIfWindows(path); doc.add(new Field(QueryBuilder.U, Util.path2uid(path, date), string_ft_stored_nanalyzed_norms)); doc.add(new Field(QueryBuilder.FULLPATH, file.getAbsolutePath(), string_ft_nstored_nanalyzed_norms)); doc.add(new SortedDocValuesField(QueryBuilder.FULLPATH, new BytesRef(file.getAbsolutePath()))); HistoryReader hr = HistoryGuru.getInstance().getHistoryReader(file); if (hr != null) { doc.add(new TextField(QueryBuilder.HIST, hr)); doc.add(new Field(QueryBuilder.DATE, date, string_ft_stored_nanalyzed_norms)); doc.add(new SortedDocValuesField(QueryBuilder.DATE, new BytesRef(date))); doc.add(new TextField(QueryBuilder.PATH, path, Store.YES)); Project project = Project.getProject(path); if (project != null) { doc.add(new TextField(QueryBuilder.PROJECT, project.getPath(), Store.YES)); if (fileParent != null && fileParent.length() > 0) { String normalizedPath = QueryBuilder.normalizeDirPath(fileParent); StringField npstring = new StringField(QueryBuilder.DIRPATH, normalizedPath, Store.NO); doc.add(npstring); Genre g = fa.getGenre(); if (g == Genre.PLAIN || g == Genre.XREFABLE || g == Genre.HTML) {
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; }
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();
@Override protected void addNewFieldToDocument( Document document, String key, Object value ) { document.add( new StringField( exactKey( key ), value.toString(), Store.YES ) ); document.add( instantiateField( key, value, TextField.TYPE_STORED ) ); document.add( instantiateSortField( key, value ) ); }
fields = globalDocumentBuilder.createDescriptorFields(image); for (Field field : fields) { doc.add(field); doc.add(field); doc.add(field); writer.addDocument(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( NODE_ID_KEY, "", YES ); idValueField = new NumericDocValuesField( NODE_ID_KEY, 0L ); document = new Document(); document.add( idField ); document.add( idValueField ); }