# Not able to reindexing restored couchdb

**URL:** <https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590>\
**Category:** Primero IMS\
**Tags:** v1-6\
**Created:** [July 20, 2022, 9:26am UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590 "2022-07-20T09:26:29Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanket252](https://primero.supporthub.dev/forum/letter_avatar_proxy/v4/letter/s/839c29/32.png) [@sanket252](https://primero.supporthub.dev/forum/u/sanket252)\
**Post date:** [July 20, 2022, 9:26am UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/1 "2022-07-20T09:26:29Z")

</div>

Trying to restore CouchDB from one server to another, but not able to reindex it using the below command.

RAILS\_ENV=production bundle exec rake sunspot:reindex

after reindexing 5 out of 7 batches, the rake is aborted with the error ArgumentError: invalid date

I have attached a screenshot for reference.

 ![Screenshot 2022-07-20 135424](https://primero.supporthub.dev/forum/uploads/primero/original/1X/59be4d9900bb77daeea3de1b767f2648cca6c724.jpeg)

---

<div class="post-metadata">

**Author:** ![childprotectioninnov](https://primero.supporthub.dev/forum/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@childprotectioninnov](https://primero.supporthub.dev/forum/u/childprotectioninnov)\
**Post date:** [July 22, 2022, 11:35am UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/2 "2022-07-22T11:35:58Z")

</div>

Dear @sanket252, which Primero implementation are you supporting including which version and country?

---

<div class="post-metadata">

**Author:** ![sanket252](https://primero.supporthub.dev/forum/letter_avatar_proxy/v4/letter/s/839c29/32.png) [@sanket252](https://primero.supporthub.dev/forum/u/sanket252)\
**Post date:** [July 25, 2022, 3:04am UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/3 "2022-07-25T03:04:22Z")

</div>

Hi @childprotectioninnov, thanks for the responce.  
We are using Primero IMS version 1.6.20 in India.

---

<div class="post-metadata">

**Author:** ![childprotectioninnov](https://primero.supporthub.dev/forum/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@childprotectioninnov](https://primero.supporthub.dev/forum/u/childprotectioninnov)\
**Post date:** [August 23, 2022, 6:41pm UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/4 "2022-08-23T18:41:23Z")

</div>

Dear @sanket252 are you running a live/production version of Primero? If not, could you try installing and running [Primero v2](https://primero.supporthub.dev/forum/t/self-hosting-primero-v2-installation/434) instead of v1.6 since we have a more up-to-date software with regular releases with v2?

---

<div class="post-metadata">

**Author:** ![sanket252](https://primero.supporthub.dev/forum/letter_avatar_proxy/v4/letter/s/839c29/32.png) [@sanket252](https://primero.supporthub.dev/forum/u/sanket252)\
**Post date:** [August 24, 2022, 5:02am UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/5 "2022-08-24T05:02:11Z")

</div>

@childprotectioninnov Yes, we are running a production instance of Primero v1.6.20

---

<div class="post-metadata">

**Author:** ![irlawrence](https://primero.supporthub.dev/forum/user_avatar/primero.supporthub.dev/irlawrence/32/8_2.png) [@irlawrence](https://primero.supporthub.dev/forum/u/irlawrence)\
**Post date:** [August 30, 2022, 6:50pm UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/6 "2022-08-30T18:50:30Z")

</div>

The issue is with the date format. Make sure they are in UTC format. From the docs

> date field shall be of the form 1995-12-31T23:59:59Z The trailing “Z” designates UTC time _and is mandatory_ Optional fractional seconds are allowed, as long as they do not end in a trailing 0 (but any precision beyond milliseconds will be ignored).

---

<div class="post-metadata">

**Author:** ![kurund](https://primero.supporthub.dev/forum/letter_avatar_proxy/v4/letter/k/b5a626/32.png) [@kurund](https://primero.supporthub.dev/forum/u/kurund)\
**Post date:** [September 20, 2022, 6:58pm UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/7 "2022-09-20T18:58:48Z")

</div>

How do we find bad date data from the DB?

---

<div class="post-metadata">

**Author:** ![irlawrence](https://primero.supporthub.dev/forum/user_avatar/primero.supporthub.dev/irlawrence/32/8_2.png) [@irlawrence](https://primero.supporthub.dev/forum/u/irlawrence)\
**Post date:** [September 20, 2022, 7:26pm UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/8 "2022-09-20T19:26:59Z")

</div>

Maybe try `RAILS_ENV=production bundle exec rake sunspot:reindex --trace` ?

---

<div class="post-metadata">

**Author:** ![kurund](https://primero.supporthub.dev/forum/letter_avatar_proxy/v4/letter/k/b5a626/32.png) [@kurund](https://primero.supporthub.dev/forum/u/kurund)\
**Post date:** [September 21, 2022, 5:13am UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/9 "2022-09-21T05:13:43Z")

</div>

`RAILS_ENV=production bundle exec rake sunspot:reindex --trace`

This just fails with the error mentioned in this issue ☹

---

<div class="post-metadata">

**Author:** ![irlawrence](https://primero.supporthub.dev/forum/user_avatar/primero.supporthub.dev/irlawrence/32/8_2.png) [@irlawrence](https://primero.supporthub.dev/forum/u/irlawrence)\
**Post date:** [September 21, 2022, 10:00am UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/10 "2022-09-21T10:00:52Z")

</div>

Did you try stopping and then starting solr?  
Either use rake stop/start or just kill the PID. You could also try removing the solr folder after stopping and before starting and it should regenerate (not tested so do at your own risk)

---

<div class="post-metadata">

**Author:** ![kurund](https://primero.supporthub.dev/forum/letter_avatar_proxy/v4/letter/k/b5a626/32.png) [@kurund](https://primero.supporthub.dev/forum/u/kurund)\
**Post date:** [September 22, 2022, 12:20pm UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/11 "2022-09-22T12:20:10Z")

</div>

I did restart the actual server and then tried to reindex using

```auto
RAILS_ENV=production bundle exec rake sunspot:reindex --trace

```

It continues to fail. Is there a way to get more information on where it’s failing?

The current error is not that useful.

```auto
rake aborted!
ArgumentError: invalid date

```

---

<div class="post-metadata">

**Author:** ![irlawrence](https://primero.supporthub.dev/forum/user_avatar/primero.supporthub.dev/irlawrence/32/8_2.png) [@irlawrence](https://primero.supporthub.dev/forum/u/irlawrence)\
**Post date:** [September 22, 2022, 9:13pm UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/12 "2022-09-22T21:13:43Z")

</div>

The only thing I can think of (apart from [upgrading](https://github.com/primeroIMS/primero-v2-migration)) is grepping through the database looking for dates without the Z at the end. So a value of “2020-10-10 23:59:59+0300” should be expressed as “2020-10-10T20:59:59Z” for solr

---

<div class="post-metadata">

**Author:** ![kurund](https://primero.supporthub.dev/forum/letter_avatar_proxy/v4/letter/k/b5a626/32.png) [@kurund](https://primero.supporthub.dev/forum/u/kurund)\
**Post date:** [September 27, 2022, 1:02pm UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/13 "2022-09-27T13:02:17Z")

</div>

@irlawrence

Thank you and apologies for the delayed response. I was offline for a few days.

I am checking data in the DB and most of the date fields are of the following format: ‘2022/03/31 00:00:00 +0000’

Re indexing is working for some data but fails for few.

Any thoughts.

---

<div class="post-metadata">

**Author:** ![irlawrence](https://primero.supporthub.dev/forum/user_avatar/primero.supporthub.dev/irlawrence/32/8_2.png) [@irlawrence](https://primero.supporthub.dev/forum/u/irlawrence)\
**Post date:** [September 27, 2022, 7:10pm UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/14 "2022-09-27T19:10:25Z")

</div>

Can you find out which dates it works/fails on? I guess some dates managed to get into the db in a form solr does not like so you need to find and edit them. It should be pretty obvious I think which they are

---

<div class="post-metadata">

**Author:** ![kurund](https://primero.supporthub.dev/forum/letter_avatar_proxy/v4/letter/k/b5a626/32.png) [@kurund](https://primero.supporthub.dev/forum/u/kurund)\
**Post date:** [October 4, 2022, 6:19pm UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/15 "2022-10-04T18:19:58Z")

</div>

@irlawrence

I am trying to find the record or date which is resulting in failure. However, not making much progress.

Error info is limited. Is there a possibility to get a more detailed error?

We have around 3K records with lots of date fields. So struggling a bit to find out the error record.

Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![kurund](https://primero.supporthub.dev/forum/letter_avatar_proxy/v4/letter/k/b5a626/32.png) [@kurund](https://primero.supporthub.dev/forum/u/kurund)\
**Post date:** [October 8, 2022, 9:09pm UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/16 "2022-10-08T21:09:44Z")

</div>

The problem was with the error handling in `sunspot` package.

There was a bad date entry `empty space` for one of the records that failed when Date.parse() tried to parse the date.

I had to debug the sunspot code to figure out the field that resulted in this issue. After correcting the record reindexing worked.

---

<div class="post-metadata">

**Author:** ![irlawrence](https://primero.supporthub.dev/forum/user_avatar/primero.supporthub.dev/irlawrence/32/8_2.png) [@irlawrence](https://primero.supporthub.dev/forum/u/irlawrence)\
**Post date:** [October 10, 2022, 1:54pm UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/17 "2022-10-10T13:54:25Z")

</div>

That’s very cool you fixed it!  
So you looked in the db for empty space in date fields? If so we can add this more generally to the main documentation

---

<div class="post-metadata">

**Author:** ![kurund](https://primero.supporthub.dev/forum/letter_avatar_proxy/v4/letter/k/b5a626/32.png) [@kurund](https://primero.supporthub.dev/forum/u/kurund)\
**Post date:** [March 9, 2023, 9:28am UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/18 "2023-03-09T09:28:35Z")

</div>

Sorry, for the delayed response. Yes, I did.

---

<div class="post-metadata">

**Author:** ![irlawrence](https://primero.supporthub.dev/forum/user_avatar/primero.supporthub.dev/irlawrence/32/8_2.png) [@irlawrence](https://primero.supporthub.dev/forum/u/irlawrence)\
**Post date:** [March 16, 2023, 6:49pm UTC](https://primero.supporthub.dev/forum/t/not-able-to-reindexing-restored-couchdb/590/19 "2023-03-16T18:49:51Z")

</div>

What was the command you ran?
