2016-10-24 5 views
1

を使用してSolrのスキームのAPIを呼び出す私はSolrjを使用してSolrのスキームのAPIを呼び出したいです。続き は私がSolrJドキュメント <a href="https://cwiki.apache.org/confluence/display/solr/Schema+API" rel="nofollow">https://cwiki.apache.org/confluence/display/solr/Schema+API</a></p> <p>に基づいてSolrj

から
curl -X POST -H 'Content-type:application/json' --data-binary '{ 
    "add-field":{ 
    "name":"sell-by", 
    "type":"tdate", 
    "stored":true } 
}' http://localhost:8983/solr/gettingstarted/schema 

を呼びたいcurlコマンドがSolrJを使用してコールする方法はありますか?

+0

あなたが持っているsolrjのバージョンは? – freedev

答えて

1

これはそれを行う必要があります。

String urlString = "http://localhost:8983/solr/gettingstarted"; 
    SolrClient solr = new HttpSolrClient.Builder(urlString).build(); 


    Map<String, Object> fieldAttributes = new LinkedHashMap<>(); 
    fieldAttributes.put("name", "sell-by"); 
    fieldAttributes.put("type", "tdate"); 
    fieldAttributes.put("stored", true); 

    SchemaRequest.AddField addFieldUpdateSchemaRequest = 
      new SchemaRequest.AddField(fieldAttributes); 
    SchemaResponse.UpdateResponse addFieldResponse = addFieldUpdateSchemaRequest.process(solr); 

SolrのスキーマAPIを使用した作業のいくつかの他のコードサンプルはSchemaTest.javaファイルで見つけることができます。

関連する問題

 関連する問題