How to use -txindex to enable blockchain transaction queries?
use 

txindex = 1


in you bitcoin.conf file and restart daemon with -reindex flag if you are building it for the first time, it might take a while but after txindex is defined you can get data for any transaction in blockchain no matter if its related to your wallet or not.  

Alternetivly you can start your daemon with 

 bitcoind -daemon -txindex=1 -reindex=1


Either way it functions the same