parent
58ed66d426
commit
68ffe6cf5b
2 changed files with 25 additions and 6 deletions
|
@ -70,9 +70,9 @@ func (db *pgDB) getBooks(active bool, query string, length int, start int) (book
|
|||
searchParams = append(searchParams, c.value)
|
||||
}
|
||||
if textQuery != "" {
|
||||
rank = append(rank, "ts_rank(tsv, to_tsquery(?))")
|
||||
rank = append(rank, "ts_rank(tsv, to_tsquery_multilingual(?))")
|
||||
rankParams = append(rankParams, textQuery)
|
||||
searchCondition += " AND to_tsquery(?) @@ tsv"
|
||||
searchCondition += " AND to_tsquery_multilingual(?) @@ tsv"
|
||||
searchParams = append(searchParams, textQuery)
|
||||
}
|
||||
|
||||
|
@ -206,8 +206,7 @@ func buildQuery(query string) (textQuery string, columnQuerys []columnq, trigram
|
|||
case "isbn":
|
||||
columnQuerys = append(columnQuerys, columnq{"isbn", value})
|
||||
case "author":
|
||||
// TODO how do we do trigram on arrays??
|
||||
trigramQuerys = append(trigramQuerys, columnq{"array_to_string(authors, ' ')", value})
|
||||
trigramQuerys = append(trigramQuerys, columnq{"text(authors)", value})
|
||||
case "title":
|
||||
trigramQuerys = append(trigramQuerys, columnq{"title", value})
|
||||
case "contributor":
|
||||
|
@ -215,9 +214,9 @@ func buildQuery(query string) (textQuery string, columnQuerys []columnq, trigram
|
|||
case "publisher":
|
||||
trigramQuerys = append(trigramQuerys, columnq{"publisher", value})
|
||||
case "subject":
|
||||
trigramQuerys = append(trigramQuerys, columnq{"array_to_string(tags, ' ')", value})
|
||||
trigramQuerys = append(trigramQuerys, columnq{"text(tags)", value})
|
||||
case "tag":
|
||||
trigramQuerys = append(trigramQuerys, columnq{"array_to_string(tags, ' ')", value})
|
||||
trigramQuerys = append(trigramQuerys, columnq{"text(tags)", value})
|
||||
default:
|
||||
if len(textQuery) != 0 {
|
||||
textQuery += " | "
|
||||
|
|
Reference in a new issue