A detective (aka investigator) is an agent who investigates crimes in order to solve them. This can be done on behalf of a government or as one's private occupation. Those who do it privately are known as a private investigator, private eye, or P.I.
Dixon Hill was a fictional 20th century Earth detective. Captain Jean-Luc Picard was fond of Dixon Hill novels, and in his free time would often escape to the holodeck where he would assume the role of Hill in holographic recreations of the detective's stories. (TNG: "The Big Goodbye", "Manhunt", "Clues"; Star Trek: First Contact)