To replace a knock sensor or not?

This mechanic I just took it to drove my car around for over 20 miles and a full tank of gas after a week and all he came up with is the knock sensor. If it were you…what would your next step be. I’ve taken it to over 5 different mechanics which includes 2 nissan dealerships only to have them throw up their hands and say they either couldn’t figure out the problem, tell me it was the knock sensor, speed sensor (which was replaced twice and wires checked and ECU checked) or tell me to come back when the CEL was on again because each time the mechanics clear the codes out. Please any suggestions would be greatly appreciated. I’ve spent over $300 now on diagnostics alone and can’t seem to get anywhere with any of the mechanics.