Before the Psalmist uttered the words, Search Me O God, he had already stated that the Lord had examined his heart and knew everything about him in Psalm 139:1 NLT and then had gone on to describe why that was the case in Psalms 139:2-22 NLT, prior to this plea that he made to God:
Search me, O God, and know my heart; test me and know my anxious thoughts. Point out anything in me that offends you, and lead me along the path of everlasting life (Psalm 139:23-24 NLT).
The Psalmist must have known something was definitely amiss within him, but he obviously didn't know exactly what had gone astray. He knew though that God knew what was not right, so he asked God to reveal what exactly he needed to repent of, so he could fully turn back to Him. How do we know that? Because "the path of everlasting life" is fully dependent on repentance. Even when saved i.e. having been born again, we cannot have anything in us that offends Jesus. We must always live a repentant lifestyle, having a broken and contrite heart (Psalm 51:17), trying our very best day today to live a life that is pleasing and right with our great God and Savior, Jesus Christ, because "once saved, always saved" or "grace plus nothing" is absolutely not true. Go to "Don't be Fooled" to read more on this subject.
In his plea to God, David said "test me". When we look at the definition of test in Strong's we find:
baw-khan'; (H974) a primitive root; to test (especially metals); generally and figuratively, to investigate:—examine, prove, tempt, try (trial).
If we visualize heat being applied to metals when they are refined, we instantly get a metaphorical picture of God applying heat to the Psalmist when he asked God to test him. Should we expect any less if we ask God to test us? It is definitely possible that our test may come with some refining "heat". The wise man helps us with this understanding:
The crucible for silver and the furnace for gold, but the Lord tests the heart (Proverbs 17:3).
But God doesn't necessarily have to be asked to test us. Just reading the Book of Job tells us that is true. Hopefully, our attitude during the test will be just like Job's was:
But he knows the way that I take; when he has tested me, I will come forth as gold (Job 23:10 NIV).
There are only two times when the word "sar`aph" is used for "thought" in the Bible. The first time is in Psalm 94:19 NIV, and then in Psalm 139:23 NIV. In the KJV, it is simply interpreted as "thought" and appears to be the same "thought" (machashabah) used elsewhere in the Bible. As you can see in the NIV, and many other translations, it is interpreted as anxious thoughts or anxiety, as opposed to just thoughts.
No doubt the Psalmist knew, that if he had any unrepentant sin within him, his thoughts would be anxious leading to a state of anxiety. Surely, as Christians, we know that when we have sinned, conviction makes us anxious until we repent. The same thing happens when God reveals a hidden sin in our lives, whether we asked Him to search us or He has decided to test us just because He loves us.
Of course, our anxiety might be based on something totally different from unrepentant sin. A good rule of thumb, though, is that if we are feeling anxious at all, have any anxiety, we should always check out first if the Comforter, the Holy Ghost, is trying to reveal sin that has not been dealt with through repentance. A repentant lifestyle allows us to stay on the path to everlasting life.