String key = cmd.getIndexedId(schema); writer.updateDocument(indexName, idTerm, cmd.getLuceneDocument(schema), schema.getAnalyzer(), shardedId, false); writer.addDocument(indexName, cmd.getLuceneDocument(schema), schema.getAnalyzer(), shardedId, false, rms);
/** schedule individual commits */ public synchronized void scheduleCommitWithin(long commitMaxTime) { _scheduleCommitWithin( commitMaxTime ); }
/** * Add the Field and value to the document, invoking the copyField mechanism * @param name The name of the field * @param val The value to add * * @see #addField(String, String, float) * @see #addField(org.apache.solr.schema.SchemaField, String, float) * @see #addSingleField(org.apache.solr.schema.SchemaField, String, float) */ public void addField(String name, String val) { addField(name, val, 1.0f); }
@Override public void processAdd(AddUpdateCommand cmd) throws IOException { cmd.doc = DocumentBuilder.toDocument(cmd.getSolrInputDocument(), req.getSchema()); updateHandler.addDoc(cmd); super.processAdd(cmd); }
/** * Commits open changes to the solr index. Does not optimize the index afterwards. * * @throws IOException iff something goes wrong */ public void commit() throws IOException { updateProcessor.processCommit(new CommitUpdateCommand(req, false)); }
@Override public void processDelete(DeleteUpdateCommand cmd) throws IOException { if( cmd.id != null ) { updateHandler.delete(cmd); } else { updateHandler.deleteByQuery(cmd); } super.processDelete(cmd); }
private void doCommit() throws IOException { CommitUpdateCommand cmd = new CommitUpdateCommand(false); cmd.waitFlush = true; cmd.waitSearcher = true; solrCore.getUpdateHandler().commit(cmd); if (solrCore.getUpdateHandler() instanceof DirectUpdateHandler2) { LOG.info("Force open index writer to make sure older index files get deleted"); DirectUpdateHandler2 handler = (DirectUpdateHandler2) solrCore.getUpdateHandler(); handler.forceOpenWriter(); replicationHandler.refreshCommitpoint(); } else { LOG.warn("The update handler is not an instance or sub-class of DirectUpdateHandler2. " + "ReplicationHandler may not be able to cleanup un-used index files."); } }
@Override public void processAdd(AddUpdateCommand cmd) throws IOException { if(!blacklistService.isBlackListed(cmd.getSolrInputDocument())){ super.processAdd(cmd); } }
protected int addNoOverwriteNoDups(AddUpdateCommand cmd) throws IOException { if (cmd.indexedId ==null) { cmd.indexedId =getIndexedId(cmd.doc); } synchronized (this) { if (existsInIndex(cmd.indexedId)) return 0; doAdd(cmd.doc); } return 1; }
protected void overwrite(String indexedId, Document doc) throws IOException { if (indexedId ==null) indexedId =getIndexedId(doc); deleteInIndex(indexedId); doAdd(doc); }
public void close() throws IOException { synchronized(this) { closeSearcher(); closeWriter(); } }
/** * @deprecated */ public SolrIndexWriter(String name, String path, boolean create, IndexSchema schema) throws IOException { super(getDirectory(path, null), false, schema.getAnalyzer(), create); init(name, schema, null); }
protected void openWriter() throws IOException { if (writer==null) { writer = createMainIndexWriter("DirectUpdateHandler2", false); } }
protected void openWriter() throws IOException { if (writer==null) { writer = createMainIndexWriter("DirectUpdateHandler", false); } }
/** * Add the specified {@link org.apache.solr.schema.SchemaField} to the document. Does not invoke the copyField mechanism. * @param sfield The {@link org.apache.solr.schema.SchemaField} to add * @param val The value to add * @param boost The boost factor * * @see #addField(String, String) * @see #addField(String, String, float) * @see #addSingleField(org.apache.solr.schema.SchemaField, String, float) */ public void addField(SchemaField sfield, String val, float boost) { addSingleField(sfield,val,boost); }
protected synchronized int allowDups(AddUpdateCommand cmd) throws IOException { doAdd(cmd.doc); return 1; }
public String toString() { return "DirectUpdateHandler2" + getStatistics(); } }
protected synchronized int overwriteBoth(AddUpdateCommand cmd) throws IOException { overwrite(cmd.indexedId, cmd.doc); return 1; }
public void forceOpenWriter() throws IOException { iwCommit.lock(); try { openWriter(); } finally { iwCommit.unlock(); } }
@Override public void processAdd(AddUpdateCommand cmd) throws IOException { SolrInputDocument doc = cmd.getSolrInputDocument(); String appid = (String)doc.getFieldValue( "appid" ); String docid = (String)doc.getFieldValue( "docid" ); doc.addField("uniqueid", appid + "-" + docid); // pass it up the chain super.processAdd(cmd); }