played with the search again.

This commit is contained in:
nek0 2015-10-18 02:51:51 +02:00
parent da09c05972
commit a410e8607b
3 changed files with 27 additions and 9 deletions

View file

@ -86,7 +86,16 @@ searchForm = renderDivs $ areq (searchField True) "Search" Nothing
getResults :: Text -> Handler (Reply, Reply, Reply, Reply) getResults :: Text -> Handler (Reply, Reply, Reply, Reply)
getResults query = do getResults query = do
let esQuery = QuerySimpleQueryStringQuery (SimpleQueryStringQuery (QueryString query) Nothing Nothing Nothing Nothing Nothing Nothing) esQuery <- return $ QueryFuzzyLikeThisQuery $ FuzzyLikeThisQuery
{ fuzzyLikeFields = [FieldName "_all"]
, fuzzyLikeText = query
, fuzzyLikeMaxQueryTerms = MaxQueryTerms 25
, fuzzyLikeIgnoreTermFrequency = IgnoreTermFrequency False
, fuzzyLikeFuzziness = Fuzziness 0.6
, fuzzyLikePrefixLength = PrefixLength 0
, fuzzyLikeBoost = Boost 1.0
, fuzzyLikeAnalyzer = Nothing
}
su <- runBH' $ searchByIndex (IndexName "user") $ mkSearch (Just esQuery) Nothing su <- runBH' $ searchByIndex (IndexName "user") $ mkSearch (Just esQuery) Nothing
sa <- runBH' $ searchByIndex (IndexName "album") $ mkSearch (Just esQuery) Nothing sa <- runBH' $ searchByIndex (IndexName "album") $ mkSearch (Just esQuery) Nothing
sm <- runBH' $ searchByIndex (IndexName "medium") $ mkSearch (Just esQuery) Nothing sm <- runBH' $ searchByIndex (IndexName "medium") $ mkSearch (Just esQuery) Nothing

View file

@ -198,6 +198,16 @@
/*custom*/ /*custom*/
#search > form
{
display: flex;
}
#search > form .required > *
{
margin: 0;
}
a:hover a:hover
{ {
color: black; color: black;

View file

@ -1,19 +1,18 @@
<div #header .item data-width="400"> <div #header .item data-width="400">
<div .inner> <div .inner>
<form method=GET action=@{SearchR}> <h1>
^{widget} Results for: #{query}
<input type="submit" value="Search">
$if allEmpty $if allEmpty
<div #header .item data-width="400"> <div #header .item data-width="400">
<div .inner> <div .inner>
<h1> <h2>
Sorry, no results Sorry, no results
$else $else
$if not $ null userList $if not $ null userList
<div #header .item data-width="400"> <div #header .item data-width="400">
<div .inner> <div .inner>
<h1> <h2>
Results in Users: Results in Users:
$forall (Entity uId user) <- userList $forall (Entity uId user) <- userList
<div #header .item data-width="400"> <div #header .item data-width="400">
@ -23,7 +22,7 @@ $else
$if not $ null albumList $if not $ null albumList
<div #header .item data-width="400"> <div #header .item data-width="400">
<div .inner> <div .inner>
<h1> <h2>
Results in Albums: Results in Albums:
$forall (Entity aId album) <- albumList $forall (Entity aId album) <- albumList
<article .item data-width="#{albumSampleWidth album}"> <article .item data-width="#{albumSampleWidth album}">
@ -37,7 +36,7 @@ $else
$if not $ null mediumList $if not $ null mediumList
<article #header .item data-width="400"> <article #header .item data-width="400">
<div .inner> <div .inner>
<h1> <h2>
Results in Media: Results in Media:
$forall (Entity mId medium) <- mediumList $forall (Entity mId medium) <- mediumList
<article .item data-width="#{mediumThumbWidth medium}"> <article .item data-width="#{mediumThumbWidth medium}">
@ -48,7 +47,7 @@ $else
$if not $ null commentList $if not $ null commentList
<div #header .item data-width="400"> <div #header .item data-width="400">
<div .inner> <div .inner>
<h1> <h2>
Results in Comments: Results in Comments:
$forall (Entity _ comment) <- commentList $forall (Entity _ comment) <- commentList
<div #header .item data-width="400"> <div #header .item data-width="400">