Solr のインスタンスがあり、solrconfig.xml で autoCommit をオンにすると、実際にニーズを満たすことができることがわかりました。ただし、自動コミットを一時的に無効にしたいインスタンスやバッチ操作がいくつかあります。私は何も見つけることができませんでしたが、SolrJを介して特定のプロセスの自動コミットを無効にしてから再度有効にできるかどうかを誰かが知っていたのでしょうか?
2805 次
2 に答える
4
solrconfig.xml で構成されているため、自動コミットを無効にして有効にすることはできません。ただし、solrconfig.xml で無効のままにして、autocommit が必要な追加コマンドにcommitWithin を使用できます。
于 2011-04-11T16:15:55.567 に答える
2
これは「solr disable autocommit」の最初の結果であるため、回答しています。
これは、コアをリロードせずに solrconfig.xml で設定された一部のプロパティをオーバーライドできる新しい構成 APIで可能になりました。
Solrj はまだその新しい API を実装していません。
自動コミットを無効にしないでください。この記事を参照してください。
一度に多数のドキュメントの一括インデックス作成を行う場合は、updateHandler.autoCommit.openSearcher=false
autoSoftCommits を設定して無効にします。
/**
* Disables the autoSoftCommit feature.
* Use {@link #reEnableAutoCommit()} to reenable.
* @throws IOException network error.
* @throws SolrServerException solr error.
*/
public void disableAutoSoftCommit() throws SolrServerException, IOException
{
// Solrj does not support the config API yet.
String command = "{\"set-property\": {" +
"\"updateHandler.autoSoftCommit.maxDocs\": -1," +
"\"updateHandler.autoSoftCommit.maxTime\": -1" +
"}}";
GenericSolrRequest rq = new GenericSolrRequest(SolrRequest.METHOD.POST, "/config", null);
ContentStream content = new ContentStreamBase.StringStream(command);
rq.setContentStreams(Collections.singleton(content));
rq.process(solrClient);
}
/**
* Undo {@link #disableAutoSoftCommit()}.
* @throws IOException network error.
* @throws SolrServerException solr error.
*/
public void reenableAutoSoftCommit() throws SolrServerException, IOException
{
// Solrj does not support the config API yet.
String command = "{\"unset-property\": [" +
"\"updateHandler.autoSoftCommit.maxDocs\"," +
"\"updateHandler.autoSoftCommit.maxTime\"" +
"]}";
GenericSolrRequest rq = new GenericSolrRequest(SolrRequest.METHOD.POST, "/config", null);
ContentStream content = new ContentStreamBase.StringStream(command);
rq.setContentStreams(Collections.singleton(content));
rq.process(solrClient);
}
オーバーライドされたプロパティは次の場所で確認できますhttp://localhost:8983/solr/<core>/config/overlay
于 2016-08-11T16:09:27.580 に答える