##// END OF EJS Templates
fixed path file_source style to match files_tree view
fixed path file_source style to match files_tree view

File last commit:

r3542:40ac848d default
r3722:2b58a8d9 new-ui
Show More
__init__.py
110 lines | 3.0 KiB | text/x-python | PythonLexer
project: added all source files and assets
r1 # -*- coding: utf-8 -*-
docs: updated copyrights to 2019
r3363 # Copyright (C) 2012-2019 RhodeCode GmbH
project: added all source files and assets
r1 #
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
"""
Index schema for RhodeCode
"""
import importlib
import logging
dan
search: add support for elastic search 6...
r3319 from rhodecode.lib.index.search_utils import normalize_text_for_matching
project: added all source files and assets
r1 log = logging.getLogger(__name__)
# leave defaults for backward compat
default_searcher = 'rhodecode.lib.index.whoosh'
default_location = '%(here)s/data/index'
dan
search: add support for elastic search 6...
r3319 ES_VERSION_2 = '2'
ES_VERSION_6 = '6'
# for legacy reasons we keep 2 compat as default
DEFAULT_ES_VERSION = ES_VERSION_2
project: added all source files and assets
r1
dan
search: add support for elastic search 6...
r3319 from rhodecode_tools.lib.fts_index.elasticsearch_engine_6 import \
ES_CONFIG # pragma: no cover
class BaseSearcher(object):
search: added basic example query block.
r1684 query_lang_doc = ''
dan
search: add support for elastic search 6...
r3319 es_version = None
name = None
search: added basic example query block.
r1684
project: added all source files and assets
r1 def __init__(self):
pass
def cleanup(self):
pass
dan
search: add option to search within a repository group.
r3441 def search(self, query, document_type, search_user,
repo_name=None, repo_group_name=None,
search: goto commit search will now use a safe search option and never...
r1411 raise_on_exc=True):
project: added all source files and assets
r1 raise Exception('NotImplemented')
dan
search: add support for elastic search 6...
r3319 @staticmethod
def query_to_mark(query, default_field=None):
"""
Formats the query to mark token for jquery.mark.js highlighting. ES could
have a different format optionally.
search: goto commit search will now use a safe search option and never...
r1411
dan
search: add support for elastic search 6...
r3319 :param default_field:
:param query:
"""
return ' '.join(normalize_text_for_matching(query).split())
@property
def is_es_6(self):
return self.es_version == ES_VERSION_6
def get_handlers(self):
return {}
dan
search: new UI for search, and repo group context search...
r3442 @staticmethod
def extract_search_tags(query):
return []
dan
search: allow quick search for path globally
r3542 @staticmethod
def escape_specials(val):
"""
Handle and escape reserved chars for search
"""
return val
dan
search: add support for elastic search 6...
r3319
def search_config(config, prefix='search.'):
project: added all source files and assets
r1 _config = {}
for key in config.keys():
if key.startswith(prefix):
_config[key[len(prefix):]] = config[key]
dan
search: add support for elastic search 6...
r3319 return _config
def searcher_from_config(config, prefix='search.'):
_config = search_config(config, prefix)
project: added all source files and assets
r1
if 'location' not in _config:
_config['location'] = default_location
dan
search: add support for elastic search 6...
r3319 if 'es_version' not in _config:
# use old legacy ES version set to 2
_config['es_version'] = '2'
project: added all source files and assets
r1 imported = importlib.import_module(_config.get('module', default_searcher))
dan
search: add support for elastic search 6...
r3319 searcher = imported.Searcher(config=_config)
project: added all source files and assets
r1 return searcher