Added shard preference setting to query

Added shard preference setting to query.