This repository was archived by the owner on Sep 13, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 11const Joi = require ( 'joi' ) ;
2- const { Op } = require ( '@datawrapper/orm' ) . db ;
2+ const { Op, literal } = require ( '@datawrapper/orm' ) . db ;
33const { decamelizeKeys, decamelize } = require ( 'humps' ) ;
44const set = require ( 'lodash/set' ) ;
55const { Chart, User } = require ( '@datawrapper/orm/models' ) ;
@@ -184,12 +184,12 @@ async function getAllCharts(request, h) {
184184
185185 if ( query . search ) {
186186 const search = [
187- { title : { [ Op . like ] : `% ${ query . search } %` } } ,
188- { metadata : { describe : { intro : { [ Op . like ] : `% ${ query . search } %` } } } } ,
189- { metadata : { describe : { byline : { [ Op . like ] : `% ${ query . search } %` } } } } ,
190- { metadata : { describe : { 'source-name' : { [ Op . like ] : `% ${ query . search } %` } } } } ,
191- { metadata : { describe : { 'source-url' : { [ Op . like ] : `% ${ query . search } %` } } } } ,
192- { metadata : { annotate : { notes : { [ Op . like ] : `% ${ query . search } %` } } } }
187+ literal (
188+ `MATCH(title, keywords) AGAINST (' ${ query . search . replace (
189+ / ' / g ,
190+ ''
191+ ) } ' IN BOOLEAN MODE)`
192+ )
193193 ] ;
194194 set ( options , [ 'where' , Op . or ] , search ) ;
195195 }
You can’t perform that action at this time.
0 commit comments