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 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
sa <- runBH' $ searchByIndex (IndexName "album") $ mkSearch (Just esQuery) Nothing
sm <- runBH' $ searchByIndex (IndexName "medium") $ mkSearch (Just esQuery) Nothing

View file

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

View file

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