Can the text output from the query ray be changed to also include the attribute entries such as material_id and others?
Yes, it can. Use the advanced dialog on the Query Ray Control Panel. The last line on that dialog is for scripts. In that line, you can add commands like "attr rgb" (without the quotes) to attach attributes to the output. Or, if you want more than one attribute you can supply the attr command a space separated list - e.g. "attr rgb material_id"
For more details on using attr, check the nirt man page. The same rules discussed there apply to Query Ray output (Query Ray in MGED actually uses nirt).