[#1838] Small refactoring on plugin's datastore_search()

I removed some unused variables, and stopped validating on _where(), as we're
already validating on datastore_validate().
[#1838] Add full-text searching on specific fields on datastore_search

You still can send queries to `datastore_search` adding a `q` parameter as a
string, and they'll work as they always had (i.e. we're backwards compatible).
But now you're able to send `q` as a dict with a string value, as in:

```json
"q": {
    "title": "CKAN"
}
```

That would do a full-text search only on the "title" field, and return the
results. I haven't created the indexes yet, so these searches can be pretty
slow.
Revert "[#1838] Small refactoring on plugin's datastore_search()"

This reverts commit 766dbe441e07bd60c4c04fb4093584493bbe4995.
[#1838] Don't add "q" filters on fields that don't exist

We simply ignore them. We can't raise errors, because there might be another
extension that does understand them, so we can't say they're actually invalid.
[#1838] Fix bg where we were limiting filters to columns on the fields param

The problem was that `_where` and `_sort` needed a list of all columns, but if
the user sent a field list using the `fields` parameter, they actually received
the list of fields in that paramter.

This fixes that.
[#1838] Add tests for current index creation code
[#1838] Create FTS indexes on each textual field

We create those indexes at the same time we're indexing `_full_text`. This is
needed to allow full-text searches on specific columns, and not only on the
entire row.

For the test, unfortunately I couldn't test that a FTS index was created for
each specific field, but instead rely on the number of indexes, because as the
index is not on the column itself, but on the return value of `to_tsvector`, we
don't have that information available.

There're still issues with this code as we're using English for default (and
there's no way to overwrite that).
[#1838] Use the default Postgres' language to create the FTS index
[#1838] Escape % from all strings that may have them

The problem we faced when doing format() twice was that if someone passed a
query with "{}", it'll look confuse the second format(). For example, the
query:

```json
{
    filters: {
        "country": "{test}"
    }
}
```

It'll confuse the second format(). So, instead of doing two formats to escape
%, we escape % before running it.
[#1838] Fix bug where we weren't converting JSON to dicts
[#1838] Always create full-text search indexes

Before this, we only created FTS indexes when the user sent a `indexes` or
`primary_key` parameter to the `datastore_create` call, which only happens when
you're directly calling it (i.e. not uploading a file through CKAN's
interface).

This makes it faster to upload something to the datastore, but creates problems
as queries aren't on indexed fields. So this commit changes it to always create
at least the full-text search indexes.
Merge branch 'master' into 1838-fts-on-specific-columns

Conflicts:
	ckanext/datastore/plugin.py
[#1838] Use assert_equal to facilitate test debugging
[#1838] Calculate FTS rankings only on specific columns

The bug was that when we've done a full-text query on a specific column, the
query was OK, but the rank was calculated using all text from the row. It
messed up when trying to get DISTINCT values.
[#1838] Fix tests where we were asserting a assert_equals
[#1838] Set default FTS language using ckan.datastore.default_fts_lang

If you set `ckan.datastore.default_fts_lang` on the INI file, it'll be used as
the default language to be used when creating full-text search indexes and
queries. It can be overwritten on a per-request basis by using the `lang`
parameter. If none exist (neither `lang` or `ckan.datastore.default_fts_lang`),
"english" is used as a default.
[#1838] Fix test on FTS indexes creation

It's really bad that I'm now testing the number of indexes created, which is
quite flaky. The problem is that we change the index name depending on if we're
working on Postgres < or > 9. This works for now, but can be improved later.
[#1838] Refactor FTS index creation
[#1838] Create index only if it doesn't exist

We do so by creating a unique index name that's specific to each pair
resource_id + field_name. Before trying to create an index, we check if an
index with this same name exist, and only create it if it doesn't.
[#1838] Refactor tests to be less flaky

Instead of asserting the number of indexes created, we now assert on the actual
index names.