1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-20 13:49:42 +02:00

Improve search by tag for MySQL

Fixes #214

MySQL requires specific full text search queries.
This commit is contained in:
Harvey Kandola 2019-02-28 13:39:53 +00:00
parent 4b7d4cf872
commit f47f09661f
4 changed files with 22 additions and 24 deletions

View file

@ -266,6 +266,11 @@ func (s Store) matchFullText(ctx domain.RequestContext, keywords, itemType strin
switch s.Runtime.StoreProvider.Type() { switch s.Runtime.StoreProvider.Type() {
case env.StoreTypeMySQL: case env.StoreTypeMySQL:
// Tag names can contain hyphens so we have to wrap text in double quotes
// and then the query parser wraps in single quotes.
if itemType == "tag" {
keywords = fmt.Sprintf("\"%s\"", keywords)
}
fts = " AND MATCH(s.c_content) AGAINST(? IN BOOLEAN MODE) " fts = " AND MATCH(s.c_content) AGAINST(? IN BOOLEAN MODE) "
case env.StoreTypePostgreSQL: case env.StoreTypePostgreSQL:
// By default, we expect no Postgres full text search operators. // By default, we expect no Postgres full text search operators.

View file

@ -29,23 +29,8 @@ export default Component.extend({
this.set('keywords', this.get('filter')); this.set('keywords', this.get('filter'));
this.set('matchFilter', this.get('matchFilter')); this.set('matchFilter', this.get('matchFilter'));
this.fetch(); this.fetch();
console.log('receive a');
}, },
didReceiveAttrs() {
this._super(...arguments);
// this.set('keywords', this.get('filter'));
this.set('matchFilter', this.get('matchFilter'));
this.fetch();
console.log('update a');
},
// didUpdateAttrs() {
// this._super(...arguments);
// this.fetch();
// console.log('update a');
// },
fetch() { fetch() {
let payload = { let payload = {
keywords: this.get('keywords'), keywords: this.get('keywords'),

View file

@ -80,15 +80,23 @@
} }
.hashtags { .hashtags {
> .hashtag {
display: inline-block; display: inline-block;
margin: 5px 10px 0 5px; padding: 0;
color: map-get($gray-shades, 600);
font-size: 1rem;
font-style: italic;
&:hover { > .hashtag {
color: $color-link; padding: 0 15px 0 0;
> .dicon {
color: map-get($gray-shades, 500);
font-size: 20px;
vertical-align: bottom;
padding: 0 5px 0 0;
}
> .name {
display: inline-block;
color: map-get($gray-shades, 800);
font-size: 1rem;
} }
} }
} }

View file

@ -1,5 +1,5 @@
{{#each tagz as |tg|}} {{#each tagz as |tg|}}
{{#link-to "search" (query-params filter=tg) class="hashtag"}} {{#link-to "search" (query-params filter=tg matchTag=true matchContent=false matchFile=false matchDoc=false) class="hashtag"}}
<i class="dicon {{constants.Icon.Tag}}" /> <i class="dicon {{constants.Icon.Tag}}" />
<div class="name">{{tg}}</div> <div class="name">{{tg}}</div>
{{/link-to}} {{/link-to}}