build date index at startup

src
Kevin Lynx 11 years ago
parent 648fe7f20d
commit ba64278d12

@ -32,6 +32,7 @@ init(Host, Port) ->
Conn.
init(Conn) ->
ensure_date_index(Conn),
case config:get(search_method, mongodb) of
mongodb ->
io:format("use mongod text search~n", []),
@ -163,10 +164,12 @@ ensure_search_index(Conn) ->
end).
ensure_date_index(Conn) ->
io:format("ensuring date index...", []),
Spec = {key, {created_at, 1}},
mongo_do(Conn, fun() ->
mongo:ensure_index(?COLLNAME, Spec)
end).
end),
io:format("done~n", []).
% not work
enable_text_search(Conn) ->

@ -114,7 +114,7 @@ search_by_sphinx(Keyword, Page) ->
{TotalFound, CostTime, DBTime} = Stats,
US = http_common:list_to_utf_binary(Keyword),
?LOG_STR(?INFO, ?FMT("search /~s/ found ~p, cost ~b sp ms, ~b db ms",
[US, length(Rets), CostTime, DBTime])),
[US, TotalFound, CostTime, DBTime / 1000])),
Tip = ?TEXT("<h4>search ~s, ~b results, ~f seconds, db ~f seconds</h4>",
[Keyword, TotalFound, CostTime / 1000, DBTime / 1000 / 1000]),
BodyList = format_search_result(Rets),

Loading…
Cancel
Save