Solr Atomic update is not working through java. Only the fields which I want to update or add appears in the new document. All the other values values are getting deleted. It works through curl. I have updated all the fields in managed-schema.xml to have value as stored. I have played around with some values in Solrconfig.xml as well, but unable to achieve atomic update.
Tried stored="true" for all the fields as suggested by Solr documentation.
public class SolrUpdate {
public static void main(String[] args) throws Exception{
SolrClient client = new HttpSolrClient.Builder("http://<hostname>:8983/solr/FTDL").build();
UpdateRequest updateRequest = new UpdateRequest();
SolrInputDocument myDocumentInstantlycommited = new SolrInputDocument();
myDocumentInstantlycommited.setField("id", "73c7ca39-4046-44f0-8922-371db0ec02d6");
myDocumentInstantlycommited.setField("name", "Rahman");
myDocumentInstantlycommited.addField("TTTTTTTTT", "Rahman");
myDocumentInstantlycommited.setField("resourcename","Updated Resource");
updateRequest.add( myDocumentInstantlycommited);
UpdateResponse rsp = updateRequest.process(client);
System.out.println("Result:"+rsp);
System.out.println("Documents Updated");
client.commit();
client.close();
}
}
Fields in Schema
<field name="TTTTTTTTT" type="text_general"/>
<field name="XYXYXYX" type="text_general"/>
<field name="_nest_path_" type="_nest_path_" stored="true"/>
<field name="_root_" type="string" docValues="false" indexed="true" stored="true"/>
<field name="_text_" type="text_general" multiValued="true" indexed="true" stored="true"/>
<field name="_version_" type="plong" indexed="false" stored="true"/>
<field name="access_permission_assemble_document" type="booleans" stored="true"/>
<field name="access_permission_can_modify" type="booleans" stored="true"/>
<field name="access_permission_can_print" type="booleans" stored="true"/>
<field name="access_permission_can_print_degraded" type="booleans" stored="true"/>
<field name="access_permission_extract_content" type="booleans" stored="true"/>
<field name="access_permission_extract_for_accessibility" type="booleans" stored="true"/>
<field name="access_permission_fill_in_form" type="booleans" stored="true"/>
<field name="access_permission_modify_annotations" type="booleans" stored="true"/>
<field name="author" type="text_general" indexed="true" stored="true"/>
<field name="commit" type="booleans" stored="true"/>
<field name="config_file" type="text_general" stored="true"/>
<field name="content" type="text_general" indexed="true" stored="true"/>
<field name="content_type" type="text_general" indexed="true" stored="true"/>
<field name="cp_subject" type="text_general" stored="true"/>
<field name="created" type="pdates" indexed="false" stored="true"/>
<field name="creation_date" type="pdates" indexed="true" stored="true"/>
<field name="creator" type="text_general" indexed="true" stored="true"/>
<field name="date" type="pdates" indexed="true" stored="true"/>
<field name="dc_creator" type="text_general" stored="true"/>
<field name="dc_description" type="text_general" stored="true"/>
<field name="dc_format" type="text_general" stored="true"/>
<field name="dc_title" type="text_general" stored="true"/>
<field name="dcterms_created" type="pdates" stored="true"/>
<field name="dcterms_modified" type="pdates" stored="true"/>
<field name="description" type="text_general" stored="true"/>
<field name="id" type="string" multiValued="false" indexed="true" required="true" stored="true"/>
<field name="last_modified" type="pdates" stored="true"/>
<field name="last_save_date" type="pdates" stored="true"/>
<field name="literal.name" type="text_general"/>
<field name="meta_author" type="text_general" stored="true"/>
<field name="meta_creation_date" type="pdates" stored="true"/>
<field name="meta_save_date" type="pdates" stored="true"/>
<field name="modified" type="pdates" stored="true"/>
<field name="name" type="text_general" stored="true"/>
<field name="pdf_docinfo_created" type="pdates" stored="true"/>
<field name="pdf_docinfo_creator" type="text_general" stored="true"/>
<field name="pdf_docinfo_creator_tool" type="text_general" stored="true"/>
<field name="pdf_docinfo_custom_config_file" type="text_general" stored="true"/>
<field name="pdf_docinfo_modified" type="pdates" stored="true"/>
<field name="pdf_docinfo_producer" type="text_general" stored="true"/>
<field name="pdf_docinfo_subject" type="text_general" stored="true"/>
<field name="pdf_docinfo_title" type="text_general" stored="true"/>
<field name="pdf_encrypted" type="booleans" stored="true"/>
<field name="pdf_pdfversion" type="pdoubles" stored="true"/>
<field name="producer" type="text_general" stored="true"/>
<field name="resourcename" type="text_general"/>
<field name="stream_size" type="text_general" stored="true"/>
<field name="subject" type="text_general" stored="true"/>
<field name="title" type="text_general" stored="true"/>
<field name="x_parsed_by" type="text_general" stored="true"/>
<field name="xmp_creatortool" type="text_general" stored="true"/>
<field name="xmpmm_documentid" type="text_general" stored="true"/>
<field name="xmptpg_npages" type="plongs" stored="true"/>
<dynamicField name="*_txt_en_split_tight" type="text_en_splitting_tight" indexed="true" stored="true"/>
<dynamicField name="*_descendent_path" type="descendent_path" indexed="true" stored="true"/>
<dynamicField name="*_ancestor_path" type="ancestor_path" indexed="true" stored="true"/>
<dynamicField name="*_txt_en_split" type="text_en_splitting" indexed="true" stored="true"/>
<dynamicField name="*_txt_sort" type="text_gen_sort" indexed="true" stored="true"/>
<dynamicField name="ignored_*" type="ignored"/>
<dynamicField name="*_txt_rev" type="text_general_rev" indexed="true" stored="true"/>
<dynamicField name="*_phon_en" type="phonetic_en" indexed="true" stored="true"/>
<dynamicField name="*_s_lower" type="lowercase" indexed="true" stored="true"/>
<dynamicField name="*_txt_cjk" type="text_cjk" indexed="true" stored="true"/>
<dynamicField name="random_*" type="random"/>
<dynamicField name="*_t_sort" type="text_gen_sort" multiValued="false" indexed="true" stored="true"/>
<dynamicField name="*_txt_en" type="text_en" indexed="true" stored="true"/>
<dynamicField name="*_txt_ar" type="text_ar" indexed="true" stored="true"/>
<dynamicField name="*_txt_bg" type="text_bg" indexed="true" stored="true"/>
<dynamicField name="*_txt_ca" type="text_ca" indexed="true" stored="true"/>
<dynamicField name="*_txt_cz" type="text_cz" indexed="true" stored="true"/>
<dynamicField name="*_txt_da" type="text_da" indexed="true" stored="true"/>
<dynamicField name="*_txt_de" type="text_de" indexed="true" stored="true"/>
<dynamicField name="*_txt_el" type="text_el" indexed="true" stored="true"/>
<dynamicField name="*_txt_es" type="text_es" indexed="true" stored="true"/>
<dynamicField name="*_txt_eu" type="text_eu" indexed="true" stored="true"/>
<dynamicField name="*_txt_fa" type="text_fa" indexed="true" stored="true"/>
<dynamicField name="*_txt_fi" type="text_fi" indexed="true" stored="true"/>
<dynamicField name="*_txt_fr" type="text_fr" indexed="true" stored="true"/>
<dynamicField name="*_txt_ga" type="text_ga" indexed="true" stored="true"/>
<dynamicField name="*_txt_gl" type="text_gl" indexed="true" stored="true"/>
<dynamicField name="*_txt_hi" type="text_hi" indexed="true" stored="true"/>
<dynamicField name="*_txt_hu" type="text_hu" indexed="true" stored="true"/>
<dynamicField name="*_txt_hy" type="text_hy" indexed="true" stored="true"/>
<dynamicField name="*_txt_id" type="text_id" indexed="true" stored="true"/>
<dynamicField name="*_txt_it" type="text_it" indexed="true" stored="true"/>
<dynamicField name="*_txt_ja" type="text_ja" indexed="true" stored="true"/>
<dynamicField name="*_txt_ko" type="text_ko" indexed="true" stored="true"/>
<dynamicField name="*_txt_lv" type="text_lv" indexed="true" stored="true"/>
<dynamicField name="*_txt_nl" type="text_nl" indexed="true" stored="true"/>
<dynamicField name="*_txt_no" type="text_no" indexed="true" stored="true"/>
<dynamicField name="*_txt_pt" type="text_pt" indexed="true" stored="true"/>
<dynamicField name="*_txt_ro" type="text_ro" indexed="true" stored="true"/>
<dynamicField name="*_txt_ru" type="text_ru" indexed="true" stored="true"/>
<dynamicField name="*_txt_sv" type="text_sv" indexed="true" stored="true"/>
<dynamicField name="*_txt_th" type="text_th" indexed="true" stored="true"/>
<dynamicField name="*_txt_tr" type="text_tr" indexed="true" stored="true"/>
<dynamicField name="*_point" type="point" indexed="true" stored="true"/>
<dynamicField name="*_srpt" type="location_rpt" indexed="true" stored="true"/>
<dynamicField name="attr_*" type="text_general" multiValued="true" indexed="true" stored="true"/>
<dynamicField name="*_txt" type="text_general" indexed="true" stored="true"/>
<dynamicField name="*_str" type="strings" docValues="true" indexed="false" stored="false" useDocValuesAsStored="false"/>
<dynamicField name="*_dts" type="pdate" multiValued="true" indexed="true" stored="true"/>
<dynamicField name="*_dpf" type="delimited_payloads_float" indexed="true" stored="true"/>
<dynamicField name="*_dpi" type="delimited_payloads_int" indexed="true" stored="true"/>
<dynamicField name="*_dps" type="delimited_payloads_string" indexed="true" stored="true"/>
<dynamicField name="*_is" type="pints" indexed="true" stored="true"/>
<dynamicField name="*_ss" type="strings" indexed="true" stored="true"/>
<dynamicField name="*_ls" type="plongs" indexed="true" stored="true"/>
<dynamicField name="*_bs" type="booleans" indexed="true" stored="true"/>
<dynamicField name="*_fs" type="pfloats" indexed="true" stored="true"/>
<dynamicField name="*_ds" type="pdoubles" indexed="true" stored="true"/>
<dynamicField name="*_dt" type="pdate" indexed="true" stored="true"/>
<dynamicField name="*_ws" type="text_ws" indexed="true" stored="true"/>
<dynamicField name="*_i" type="pint" indexed="true" stored="true"/>
<dynamicField name="*_s" type="string" indexed="true" stored="true"/>
<dynamicField name="*_l" type="plong" indexed="true" stored="true"/>
<dynamicField name="*_t" type="text_general" multiValued="false" indexed="true" stored="true"/>
<dynamicField name="*_b" type="boolean" indexed="true" stored="true"/>
<dynamicField name="*_f" type="pfloat" indexed="true" stored="true"/>
<dynamicField name="*_d" type="pdouble" indexed="true" stored="true"/>
<dynamicField name="*_p" type="location" indexed="true" stored="true"/>
<copyField source="pdf_docinfo_creator_tool" dest="pdf_docinfo_creator_tool_str" maxChars="256"/>
<copyField source="subject" dest="subject_str" maxChars="256"/>
<copyField source="x_parsed_by" dest="x_parsed_by_str" maxChars="256"/>
<copyField source="description" dest="description_str" maxChars="256"/>
<copyField source="cp_subject" dest="cp_subject_str" maxChars="256"/>
<copyField source="dc_description" dest="dc_description_str" maxChars="256"/>
<copyField source="title" dest="title_str" maxChars="256"/>
<copyField source="meta_author" dest="meta_author_str" maxChars="256"/>
<copyField source="content" dest="content_str" maxChars="256"/>
<copyField source="content_type" dest="content_type_str" maxChars="256"/>
<copyField source="pdf_docinfo_creator" dest="pdf_docinfo_creator_str" maxChars="256"/>
<copyField source="xmp_creatortool" dest="xmp_creatortool_str" maxChars="256"/>
<copyField source="pdf_docinfo_title" dest="pdf_docinfo_title_str" maxChars="256"/>
<copyField source="config_file" dest="config_file_str" maxChars="256"/>
<copyField source="stream_size" dest="stream_size_str" maxChars="256"/>
<copyField source="creator" dest="creator_str" maxChars="256"/>
<copyField source="author" dest="author_str" maxChars="256"/>
<copyField source="dc_format" dest="dc_format_str" maxChars="256"/>
<copyField source="pdf_docinfo_custom_config_file" dest="pdf_docinfo_custom_config_file_str" maxChars="256"/>
<copyField source="dc_creator" dest="dc_creator_str" maxChars="256"/>
<copyField source="pdf_docinfo_subject" dest="pdf_docinfo_subject_str" maxChars="256"/>
<copyField source="dc_title" dest="dc_title_str" maxChars="256"/>
<copyField source="xmpmm_documentid" dest="xmpmm_documentid_str" maxChars="256"/>
<copyField source="name" dest="name_str" maxChars="256"/>
<copyField source="producer" dest="producer_str" maxChars="256"/>
<copyField source="pdf_docinfo_producer" dest="pdf_docinfo_producer_str" maxChars="256"/>
<copyField source="literal.name" dest="literal.name_str" maxChars="256"/>
<copyField source="resourcename" dest="resourcename_str" maxChars="256"/>
<copyField source="XYXYXYX" dest="XYXYXYX_str" maxChars="256"/>
<copyField source="TTTTTTTTT" dest="TTTTTTTTT_str" maxChars="256"/>
</schema>
Expected Result: New fields should get appened to the list of documents. Also, existing fields should get updated with the new value.
Actual result: All the other fields are getting removed out. Also, now it is not complaining for new fields which are not predefined in schema. On the contrary, they are getting added to the schema itself. Fields "XYXYXYX" and "TTTTTTTTT" are examples of that.