The major pentatonic removes the notes in the 4th and 7th degree of the major scale. Those are notes which differentiate Ionian from Lydian. You don't have to worry if the Harmony calls for Lydian or not, because the 4 is eliminated from the scale entirely.
The minor pentatonic removes the notes in the 2nd and 6th degree of the minor scales. Those notes differentiate the Dorian from the Aeolian from the Phrygian.
Here's a PDF with the major, minor and dominant scales and their use in playing over chords.
If you play A minor pentatonic and play F# instead of G, you are playing the relative notes in the D7 Pentatonic (which of course would start on the D). The pdf shows these scales on the fingerboard.
Going from the A minor Pentatonic to a D7 pentatonic, is -- you guessed it -- a 2-5 change, which would resolve to Gmaj.
Here's an article on how to use pentatonics over different chords. For instance, you can play a Bm pentatonic over a Cmaj7(#11) chord. You can also play the D7 pentatonic over the same chord. Below is a chart on what dominant scales can be played over what chords.