The reason behind working on ID column and throwing error on other column type is very simple and clear.
We aware about the fact that if we want to fetch data or filter data from list containing more than 5000 items, we will need to use indexed column.
And index of ID column is by default maintained by SharePoint. So if you need to filter data using other column except ID, you need to do indexing on it.
How to do indexing is already shown by Tarun. In addition to this I would like to share some more interesting fact about Indexing.
Not all column type supports indexing. The supported column type for indexing are:
- Single line of text
- Choice field (but not multichoice)
- Number
- Currency
- Date/ Time
- Lookup (but not multivalue)
- Person or Group (but not multivalue)
- Title (but not in a document library)
And the column which does not support indexing are:
- Multiple lines of text
- Hyperlink/Picture
- Custom Field Types
- Calculated Field
- Boolean (yes/no)
- UI version
- Checked out to
- Content type ID
So, please keep this things in mind while indexing any column. I found the reference here