diff --git a/src/http_front/db_frontend.erl b/src/http_front/db_frontend.erl index b1f953a..7deecd9 100644 --- a/src/http_front/db_frontend.erl +++ b/src/http_front/db_frontend.erl @@ -33,7 +33,7 @@ search(Keyword, Page, Count) -> mongodb -> db_store_mongo:search(Conn, Keyword); sphinx -> - Offset = Page * Count - if Page > 0 -> 1; true -> 0 end, + Offset = Page * Count, sphinx_search:search(Conn, Keyword, Offset, Count) end. diff --git a/src/http_front/http_handler.erl b/src/http_front/http_handler.erl index e445e76..05f76d4 100644 --- a/src/http_front/http_handler.erl +++ b/src/http_front/http_handler.erl @@ -110,15 +110,14 @@ search_by_mongo(Keyword) -> Tip ++ Body. search_by_sphinx(Keyword, Page) -> - {Rets, Stats} = db_frontend:search(Keyword, Page, ?COUNT_PER_PAGE + 1), + {Rets, Stats} = db_frontend:search(Keyword, Page, ?COUNT_PER_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])), - ThisPage = lists:sublist(Rets, ?COUNT_PER_PAGE), Tip = ?TEXT("