Reputation: 4973
I am using Solr 7.7.2
version. I have defined field called date_test
with type tdate(TrieDateField)
as given below inside the {core}/conf/schema.xml
file
<field name="date_test" type="tdate" docValues="true" indexed="true" stored="true" required="false" multiValued="true" />
Inside the {core}/conf/solrconfig.xml
I can see this date format is defined here,
<updateProcessor class="solr.ParseDateFieldUpdateProcessorFactory" name="parse-date">
<arr name="format">
<str>yyyy-MM-dd'T'HH:mm:ss.SSSZ</str>
<str>yyyy-MM-dd'T'HH:mm:ss,SSSZ</str>
<str>yyyy-MM-dd'T'HH:mm:ss.SSS</str>
<str>yyyy-MM-dd'T'HH:mm:ss,SSS</str>
<str>yyyy-MM-dd'T'HH:mm:ssZ</str>
<str>yyyy-MM-dd'T'HH:mm:ss</str>
<str>yyyy-MM-dd'T'HH:mmZ</str>
<str>yyyy-MM-dd'T'HH:mm</str>
<str>yyyy-MM-dd HH:mm:ss.SSSZ</str>
<str>yyyy-MM-dd HH:mm:ss,SSSZ</str>
<str>yyyy-MM-dd HH:mm:ss.SSS</str>
<str>yyyy-MM-dd HH:mm:ss,SSS</str>
<str>yyyy-MM-dd HH:mm:ssZ</str>
<str>yyyy-MM-dd HH:mm:ss</str>
<str>yyyy-MM-dd HH:mmZ</str>
<str>yyyy-MM-dd HH:mm</str>
<str>yyyy-MM-dd</str>
</arr>
</updateProcessor>
Also, I can see this bean is used inside the updateRequestProcessorChain
as given below,
<updateRequestProcessorChain name="add-unknown-fields-to-the-schema" default="${update.autoCreateFields:false}"
processor="uuid,remove-blank,field-name-mutating,parse-boolean,parse-long,parse-double,parse-date,add-schema-fields">
<processor class="solr.LogUpdateProcessorFactory"/>
<processor class="solr.DistributedUpdateProcessorFactory"/>
<processor class="solr.RunUpdateProcessorFactory"/>
</updateRequestProcessorChain>
Now, when I try to post the document using curl with yyyy-MM-dd
format like below,
curl -X POST -d '{"add":{ "doc":{"id":"delete.me1","messageid":"message.delete.me1","date_test":"2020-01-10"}}}' -H "Content-Type: application/json" http://{ip}:8983/solr/test-data/update?commit=true
This give me error like
{
"responseHeader":{
"status":400,
"QTime":4},
"error":{
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","org.apache.solr.common.SolrException"],
"msg":"ERROR: [doc=message.delete.me1] Error adding field 'date_test'='2020-01-10' msg=Invalid Date String:'2020-01-10'",
"code":400}}
I am trying to understand why this format is not accepted even if we have format defined inside the ParseDateFieldUpdateProcessorFactory
Can someone help? Thanks in advance.
Upvotes: 1
Views: 892
Reputation: 16035
It seems your processor chain is not enabled :default="${update.autoCreateFields:false}"
.
You might need to check if update.autoCreateFields
is set in your config because it actually fallback to false. You need to set it to true :
bin/solr config -c <collection> -p <port> -action set-user-property -property update.autoCreateFields -value true
Upvotes: 2