@@ -80,24 +80,25 @@ CHGSETS_SCHEMA = Schema(
repository=ID(unique=True, stored=True),
author=TEXT(stored=True),
message=FieldType(format=Characters(), analyzer=ANALYZER,
scorable=True, stored=True),
parents=TEXT(),
added=TEXT(),
removed=TEXT(),
changed=TEXT(),
)
CHGSET_IDX_NAME = 'CHGSET_INDEX'
class MakeIndex(BasePasterCommand):
max_args = 1
min_args = 1
usage = "CONFIG_FILE"
summary = "Creates index for full text search given configuration file"
group_name = "RhodeCode"
takes_config_file = -1
parser = Command.standard_parser(verbose=True)
def command(self):
@@ -209,24 +210,29 @@ class WhooshResultWrapper(object):
def get_full_content(self, docid):
res = self.searcher.stored_fields(docid[0])
log.debug('result: %s' % res)
if self.search_type == 'content':
full_repo_path = jn(self.repo_location, res['repository'])
f_path = res['path'].split(full_repo_path)[-1]
f_path = f_path.lstrip(os.sep)
content_short = self.get_short_content(res, docid[1])
res.update({'content_short': content_short,
'content_short_hl': self.highlight(content_short),
'f_path': f_path
})
elif self.search_type == 'path':
res.update({'f_path': f_path})
elif self.search_type == 'message':
res.update({'message_hl': self.highlight(res['message'])})
return res
def get_short_content(self, res, chunks):
return ''.join([res['content'][chunk[0]:chunk[1]] for chunk in chunks])
def get_chunks(self):
@@ -81,12 +81,19 @@ class TestSearchController(TestControlle
#HG
response.mustcontain('3803844fdbd3b711175fc3da9bdacfcd6d29a6fb')
#GIT
response.mustcontain('ff7ca51e58c505fec0dd2491de52c622bb7a806b')
def test_search_author(self):
self.log_user()
response = self.app.get(url(controller='search', action='index'),
{'q': 'author:marcin@python-blog.com raw_id:b986218ba1c9b0d6a259fac9b050b1724ed8e545',
'type': 'commit'})
response.mustcontain('1 results')
def test_search_file_name(self):
{'q': 'README.rst', 'type': 'path'})
response.mustcontain('2 results')
\ No newline at end of file
Status change: