add reindex hint.
All checks were successful
Deploy / Build (push) Successful in 5m27s

This commit is contained in:
amass 2025-01-07 17:18:20 +08:00
parent 48c2ef7baa
commit aaaeb4429f
2 changed files with 41 additions and 7 deletions

View File

@ -269,9 +269,10 @@ Application::Application(const std::string &path)
using namespace boost::beast; using namespace boost::beast;
auto key = getMeiliSearchApiKey(); auto key = getMeiliSearchApiKey();
auto config = getMeiliSearchConfig(); auto config = getMeiliSearchConfig();
boost::json::object reply;
if (!key.empty() && !config.empty()) { if (!key.empty() && !config.empty()) {
config = std::filesystem::absolute(config); config = std::filesystem::absolute(config);
LOG(info)<<"config path: "<<config; LOG(info) << "config path: " << config;
boost::process::process process(session.executor(), "/usr/bin/docker", {"run", "-t", "--rm", "--network=host", boost::process::process process(session.executor(), "/usr/bin/docker", {"run", "-t", "--rm", "--network=host",
"--env=MEILISEARCH_HOST_URL=http://localhost:7700", "--env=MEILISEARCH_HOST_URL=http://localhost:7700",
std::format("--env=MEILISEARCH_API_KEY={}", key), std::format("--env=MEILISEARCH_API_KEY={}", key),
@ -281,16 +282,17 @@ Application::Application(const std::string &path)
}); });
boost::process::error_code error; boost::process::error_code error;
int code = process.wait(error); int code = process.wait(error);
if (error) { reply["status"] = code;
LOG(error) << error.message(); reply["message"] = error ? error.message() : "succeed.";
} else { } else {
LOG(info) << "reindex code:" << code; reply["status"] = 404;
} reply["message"] = "please fill MeiliSearchApiKey and MeiliSearchConfig.";
} }
http::response<boost::beast::http::string_body> s{boost::beast::http::status::ok, request.version()}; http::response<boost::beast::http::string_body> s{boost::beast::http::status::ok, request.version()};
s.set(http::field::server, BOOST_BEAST_VERSION_STRING); s.set(http::field::server, BOOST_BEAST_VERSION_STRING);
s.set(http::field::content_type, "application/json;charset=UTF-8"); s.set(http::field::content_type, "application/json;charset=UTF-8");
s.keep_alive(request.keep_alive()); s.keep_alive(request.keep_alive());
s.body() = boost::json::serialize(reply);
s.prepare_payload(); s.prepare_payload();
session.reply(std::move(s)); session.reply(std::move(s));
}); });

View File

@ -0,0 +1,32 @@
{
"index_uid": "amass_blog",
"start_urls": [
"https://amass.fun/"
],
"sitemap_urls": [
"https://amass.fun/sitemap.xml"
],
"sitemap_alternate_links": true,
"stop_urls": [
"https://amass.fun/gitea"
],
"selectors": {
"lvl0": {
"selector": "(//ul[contains(@class,'menu__list')]//a[contains(@class, 'menu__link menu__link--sublist menu__link--active')]/text() | //nav[contains(@class, 'navbar')]//a[contains(@class, 'navbar__link--active')]/text())[last()]",
"type": "xpath",
"global": true,
"default_value": "Documentation"
},
"lvl1": "header h1",
"lvl2": "article h2",
"lvl3": "article h3",
"lvl4": "article h4",
"lvl5": "article h5, article td:first-child",
"lvl6": "article h6",
"text": "article p, article li, article td:last-child"
},
"strip_chars": " .,;:#",
"custom_settings": {
},
"nb_hits": 46250
}