-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/seasearch add wiki search sup #366
base: master
Are you sure you want to change the base?
Changes from 2 commits
444663d
665b2b8
4ddbd6b
7110744
a684189
7e21984
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,8 @@ | |
|
||
from seafevents.seasearch.utils import need_index_metadata_info | ||
from seafevents.db import init_db_session_class | ||
from seafevents.seasearch.utils.constants import ZERO_OBJ_ID, REPO_FILENAME_INDEX_PREFIX | ||
from seafevents.seasearch.utils.constants import ZERO_OBJ_ID, REPO_FILENAME_INDEX_PREFIX, \ | ||
WIKI_INDEX_PREFIX | ||
from seafevents.repo_metadata.metadata_server_api import MetadataServerAPI | ||
from seafevents.repo_metadata.utils import METADATA_TABLE | ||
from seafevents.utils import timestamp_to_isoformat_timestr | ||
|
@@ -74,3 +75,48 @@ def delete_repo_filename_index(self, repo_id, repo_filename_index, repo_status_f | |
|
||
def keyword_search(self, query, repos, repo_filename_index, count, suffixes=None, search_path=None): | ||
return repo_filename_index.search_files(repos, query, 0, count, suffixes, search_path) | ||
|
||
def delete_wiki_index(self, wiki_id, wiki_index, wiki_status_index): | ||
# first delete wiki_index | ||
wiki_index_name = WIKI_INDEX_PREFIX + wiki_id | ||
wiki_index.delete_index_by_index_name(wiki_index_name) | ||
wiki_status_index.delete_documents_by_repo(wiki_id) | ||
|
||
def keyword_search(self, query, repos, repo_filename_index, count, suffixes=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 上面有一个 keyword_search 了 |
||
return repo_filename_index.search_files(repos, query, 0, count, suffixes) | ||
|
||
def wiki_search(self, query, wikis, wiki_index, count): | ||
return wiki_index.search_wikis(wikis, query, 0, count) | ||
|
||
def update_wiki_index(self, wiki_id, commit_id, wiki_index, wiki_status_index): | ||
try: | ||
new_commit_id = commit_id | ||
index_name = WIKI_INDEX_PREFIX + wiki_id | ||
|
||
wiki_index.create_index_if_missing(index_name) | ||
|
||
wiki_status = wiki_status_index.get_repo_status_by_id(wiki_id) | ||
from_commit = wiki_status.from_commit | ||
to_commit = wiki_status.to_commit | ||
|
||
if new_commit_id == from_commit: | ||
return | ||
|
||
if not from_commit: | ||
commit_id = ZERO_OBJ_ID | ||
else: | ||
commit_id = from_commit | ||
|
||
if wiki_status.need_recovery(): | ||
logger.warning('%s: wiki index inrecovery', wiki_id) | ||
wiki_index.update(index_name, wiki_id, commit_id, to_commit) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 按照现在的逻辑这里还能正常recovery吗? |
||
commit_id = to_commit | ||
time.sleep(1) | ||
wiki_status_index.begin_update_repo(wiki_id, commit_id, new_commit_id) | ||
wiki_index.update(index_name, wiki_id, commit_id, new_commit_id) | ||
wiki_status_index.finish_update_repo(wiki_id, new_commit_id) | ||
|
||
logger.info('wiki: %s, update wiki index success', wiki_id) | ||
|
||
except Exception as e: | ||
logger.exception('wiki_id: %s, update wiki index error: %s.', wiki_id, e) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,6 +159,8 @@ def search_files(self, repos, keyword, start=0, size=10, suffixes=None, search_p | |
bulk_search_params.append(data) | ||
search_path = None | ||
|
||
|
||
logger.debug('search in repo_filename_index params: %s', json.dumps(bulk_search_params)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个去掉 |
||
results = self.seasearch_api.m_search(bulk_search_params) | ||
files = [] | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是老版wiki的配置