LoginSignup
0
0

More than 5 years have passed since last update.

Apache Solr 7.6 で日付のフィールドを使う

Last updated at Posted at 2019-01-11

フィールドの定義

Typeに「pdate」を指定する

SolrJ での追加

format には「"yyyy-MM-dd'T'HH:flag_mm:ss"」を使う。


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

SolrInputDocument document = new SolrInputDocument();
document.addField("id", "5");
document.addField("field_text_en", "This is test. for Date formatting ");
String dateNow = (new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")).format(new Date());
document.addField("field_date", dateNow);
UpdateResponse response = solr.add(document);
System.err.println(response);
solr.commit();


0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0