2016-08-04 3 views
2

私はにドキュメントを1つずつ追加するのにsolrClient.add(SolrInputDocument doc)メソッドを使用しています。私は明示的にsolrClient.commit()solrj:追加後に明示的コミットが必要ですか?

を呼び出し、この後

は、それが必要ですか?私はaddメソッドを見たことがあり、commitの場合はdelayとなります。 これは何を意味しますか?単純なaddメソッドはコミットしませんか?私たちは主に二つの異なる種類を持ってSolrのでは

答えて

3

コミット:

ハードをコミットします。これは、クライアントからsolrconfig.xmlまたは明示的な呼び出しではautoCommitオプション(SolrJまたはHTTP経由で支配されています ブラウザ、cURLなど)。ハードコミットは現在のセグメント を切り捨て、インデックスに新しいセグメントを開きます。 openSearcher:新たにコミットされた データが後続の検索で見えるようにするかどうかを制御するブール値 のサブプロパティ

ソフトコミット:ハードコミット(openSearcher = true)より安価な操作で、ドキュメントを検索可能にします。

上記のテキストは、thisソースから引用しています。追加情報があります。
ドキュメントを追加すると、上記のコミットのいずれかが発生するまでコミットされません。 solrconfig.xmlで、コミットオプションのデフォルト値を確認できます。 通常は、アプリケーションのニーズに応じてハードおよびソフトのコミット時間を調整し、エントリをディスクに直接書き込む必要がない限り、コードから明示的にコミットする必要はありません。

<!-- AutoCommit 

     Perform a hard commit automatically under certain conditions. 
     Instead of enabling autoCommit, consider using "commitWithin" 
     when adding documents. 

     http://wiki.apache.org/solr/UpdateXmlMessages 

     maxDocs - Maximum number of documents to add since the last 
        commit before automatically triggering a new commit. 

     maxTime - Maximum amount of time in ms that is allowed to pass 
        since a document was added before automatically 
        triggering a new commit. 
     openSearcher - if false, the commit causes recent index changes 
      to be flushed to stable storage, but does not cause a new 
      searcher to be opened to make those changes visible. 

     If the updateLog is enabled, then it's highly recommended to 
     have some sort of hard autoCommit to limit the log size. 
     --> 
     <autoCommit> 
     <maxTime>600000</maxTime> 
     <openSearcher>false</openSearcher> 
    </autoCommit> 

    <!-- softAutoCommit is like autoCommit except it causes a 
     'soft' commit which only ensures that changes are visible 
     but does not ensure that data is synced to disk. This is 
     faster and more near-realtime friendly than a hard commit. 
     --> 

    <autoSoftCommit> 
     <maxTime>30000</maxTime> 
    </autoSoftCommit> 

Solrにはで、SoftCommitに自動的にドキュメントを行います30秒ごとに実行されます:あなたは次のように柔らかくhardcommit設定を含めるために、あなたのsolrconfig.xmlを変更した場合、より具体的には

Searchに表示され、10分ごとに強制コミットされます。

solrClient.add(SolrInputDocument doc) 

はsolrClient.commit()の呼び出しを必要とせず、10分後に30秒とハードコミット後にコミットソフトになります:あなたが使用してSolrJで追加何でもそう 、。

+0

質問の文脈で説明できますか? – gaurav5430

関連する問題