Skip to content

Commit

Permalink
Switched ranking algorithm to more suitable for shorter texts.
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Sep 3, 2012
1 parent d0eb70a commit 3f26a1c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions ckanext/datastore/db.py
Expand Up @@ -20,6 +20,7 @@
'%m-%d-%Y',
]


def _is_valid_field_name(name):
'''
Check that field name is valid:
Expand Down Expand Up @@ -146,6 +147,7 @@ def check_fields(context, fields):
'fields': ['{0} is not a valid field name'.format(field['id'])]
})


def convert(data, type):
if data is None:
return None
Expand All @@ -157,6 +159,7 @@ def convert(data, type):
return data
return unicode(data)


def create_table(context, data_dict):
'Create table from combination of fields and first row of data.'

Expand Down Expand Up @@ -362,16 +365,11 @@ def _textsearch_query(data_dict):
else:
statement = ", to_tsquery('{lang}', '{query}') query"

rank_column = ', ts_rank_cd(_full_text, query, 32) AS rank'
rank_column = ', ts_rank(_full_text, query, 32) AS rank'
return statement.format(lang=lang, query=q), rank_column
return '', ''


def _rank_column(data_dict):
if data_dict.get('plain'):
return ', ts_rank_cd(_full_text, query, 32) AS rank'


def _sort(context, data_dict, field_ids):
sort = data_dict.get('sort')
if not sort:
Expand Down

0 comments on commit 3f26a1c

Please sign in to comment.