2

I am using Solr 5.3.1 in schemaless mode. The server is running.

I can add a timestamp field to my managed-schema

<field name="timestamp" type="date" indexed="true" stored="true" default="NOW" multiValued="false"/>

By POST'ing to the /schema endpoint.

That's fine. But afterwards, Solr doesn't automatically add the field to my documents when they are being inserted.

Do I need to restart?

Do I have to index the document with timestamp specified but blank?

Is there a way to automatically add it to all documents regardless of if it has a timestamp attribute?

Community
  • 1
  • 1
FGreg
  • 14,110
  • 10
  • 68
  • 110
  • The `default` value should be invoked (it used to be, at least) for timestamp fields as well. Do you get a value if you provide a timestamp in the correct format as the default value? – MatsLindh May 20 '16 at 18:59
  • @MatsLindh Actually it's not doing anything with the new field. I tried adding a document with a blank `timestamp`, nothing. If I add a document with a valid timestamp, it does add it to the index. I updated the question to clarify I am adding the field to a running Solr, would that change things? – FGreg May 20 '16 at 19:48
  • Most changes used to require a core reload, but I'm not sure about how the managed schema changes things. Can you see the field if you show the current schema under the admin interface? – MatsLindh May 21 '16 at 21:14
  • @MatsLindh Yes it shows up in the admin interface. I think I probably need to restart the server. – FGreg May 23 '16 at 14:14

1 Answers1

1

A restart of the Solr Server was required. After restarting, all documents added included the new timestamp field.

FGreg
  • 14,110
  • 10
  • 68
  • 110
  • Do we still need to restart the Solr Server in the Solr version 6.6.1 ? Please share – Karan Jan 30 '18 at 07:19
  • @Karan I have not tested on 6.6.1 but my guess would be yes it is still needed. There shouldn't be much risk in just trying it without a restart though and seeing if your docs get inserted with the timestamp. – FGreg Jan 30 '18 at 17:36
  • 2
    There is only need to reload the core after the schema change and no need to restart the Solr server. I tried in the 6.6.1 version. – Karan Feb 01 '18 at 13:01
  • As @Karan said, a reload of the core also works `curl "http://localhost:8983/solr/admin/cores?action=RELOAD&core=your-core"` – Hector Correa Oct 03 '19 at 15:21