Basic support for link queries

This PR adds support for link queries - see issue #617. The core library does not support:

* queries on binary data (`NSData`)
* case insensitive queries on strings (`NSString`)
* predicates `BEGINSWITH`, `ENDSWITH`, and `CONTAINS` for strings

@alazier @jpsim @bmunkholm 
That's fine for now I guess. After this we should take a step back though and figure out how to make things less ugly in general - it seems we are approaching the limit of what we can do cleanly with the current design.