Mac El Capitan Spotlight XPC Connection Invalidated

I first started using El Capitan when the public beta was released. I continued to enjoy the snapping operating system until one day my laptop's SATA cable decided to give up on me. I got the cable replaced and then ended up having to reformat everything and restart over. That's when I made the decision of moving from the public beta to the official release, because I had been facing minor bluetooth connectivity issues. Ever since then, my computer has been horrible slow, freezing every 4 - 5 minutes for 20 - 30 second durations. I believe this is also called "beach-balling". Anyhow, I started to notice that every time my computer freezes, there is a "Spotlight: XPC Connection Invalidated" error in my console. Every single time. That can't be any coincidence. I've also managed to do some google searches and many people seem to face this problem. However, no one has been able to fix the problem.

These are my final days of IB, meaning I need to be submitting my final documents soon and I really need this computer to be working. I hope somebody out here can help me, I'd be more than willing to conduct any debugging tests and providing any information that can help.

Error Console #1

Error Console #2

Edit:

DriveDX Log:

Advanced SMART Status                : FAILING
Overall Health Rating                : AVERAGE 53.3%
Overall Performance Rating           : AVERAGE 53.3%
Issues found                         : 3
=== PROBLEMS SUMMARY ===
Failed Indicators (life-span / pre-fail)  : 0 (0 / 0)
Failing Indicators (life-span / pre-fail) : 1 (0 / 1)
Warnings (life-span / pre-fail)           : 2 (2 / 0)
Recently failed Self-tests (Short / Full) : 0 (0 / 0)
I/O Errors Count                          : 0 (0 / 0)
Time in Under temperature                 : 0 minutes
Time in Over temperature                  : 0 minutes

Based on your question and the subsequent conversation where you provided the SMART Status of your internal drive, your hard drive is failing and causing the issue you are experiencing.

You need to replace your hard drive. The good news is that it is not very expensive.

Your Macbook which identified by DriveDX as a MacBookPro9,2 (Mid 2012) uses a standard SATA drive and you can upgrade to an SSD and increase your performance dramatically pretty inexpensively (at the time of this, they are trending about $150 USD). I have used Samsung drives with great success. Changing it out only requires removing 10 phillips screws.

I have more info on how to do this on this post: My Mac is getting really slow, what should I do?

IMO, I would keep this running for a few more year because Apple has now made it impossible to upgrade your RAM or HDD meaning you must configure it with what you hope you are going to need in the future.