Skip to content
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

WIP: migrate search engine to full-text-search package (#748) #968

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions Distribution/Server/Features/Search.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Distribution.Server.Features.Search (
defaultSearchRankParameters,
SearchEngine.SearchRankParameters(..),
PkgDocField, PkgDocFeatures,
BM25F.Explanation(..),
SearchEngine.Explanation(..),
) where

import Distribution.Server.Framework
Expand All @@ -17,9 +17,7 @@ import Distribution.Server.Features.Core
import Distribution.Server.Features.PackageList

import Distribution.Server.Features.Search.PkgSearch
import Distribution.Server.Features.Search.SearchEngine (SearchRankParameters(..))
import qualified Distribution.Server.Features.Search.SearchEngine as SearchEngine
import qualified Distribution.Server.Features.Search.BM25F as BM25F
import qualified Data.SearchEngine as SearchEngine
import qualified Distribution.Server.Packages.PackageIndex as PackageIndex

import Distribution.Server.Packages.Types
Expand All @@ -40,10 +38,10 @@ data SearchFeature = SearchFeature {

searchPackages :: forall m. MonadIO m => [String] -> m [PackageName],
searchPackagesExplain :: forall m. MonadIO m
=> SearchRankParameters PkgDocField PkgDocFeatures
=> PkgSearchRankParameters
-> [String]
-> m (Maybe PackageName,
[(BM25F.Explanation PkgDocField PkgDocFeatures T.Text
[(SearchEngine.Explanation PkgDocField PkgDocFeatures T.Text
,PackageName)])
}

Expand All @@ -62,7 +60,7 @@ initSearchFeature env@ServerEnv{serverTemplatesDir, serverTemplatesMode} = do

searchEngineState <- newMemStateWHNF initialPkgSearchEngine

return $ \core@CoreFeature{..} list -> do
return $ \core list -> do
let feature = searchFeature env core list
searchEngineState templates

Expand Down Expand Up @@ -157,15 +155,15 @@ searchFeature ServerEnv{serverBaseURI} CoreFeature{..} ListFeature{getAllLists}
return results

searchPackagesExplain :: MonadIO m
=> SearchRankParameters PkgDocField PkgDocFeatures
=> PkgSearchRankParameters
-> [String]
-> m (Maybe PackageName, [(BM25F.Explanation PkgDocField PkgDocFeatures T.Text, PackageName)])
-> m (Maybe PackageName, [(SearchEngine.Explanation PkgDocField PkgDocFeatures T.Text, PackageName)])
searchPackagesExplain params terms = do
se <- readMemState searchEngineState
let results = SearchEngine.queryExplain
(SearchEngine.setRankParams params se)
(map T.pack terms)
return results
return (Nothing, results) -- TODO: no exact match available from the full-text-search version of queryExplain

handlerGetOpenSearch :: DynamicPath -> ServerPartE Response
handlerGetOpenSearch _ = do
Expand Down
191 changes: 0 additions & 191 deletions Distribution/Server/Features/Search/BM25F.hs

This file was deleted.

26 changes: 0 additions & 26 deletions Distribution/Server/Features/Search/DocFeatVals.hs

This file was deleted.

Loading