Skip to content

Commit

Permalink
test (#4022)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonxuxu authored and jywarren committed Nov 22, 2018
1 parent 4c2887c commit ba05350
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ def self.search(query:, order: :default, type: :natural, limit: 25)

if ActiveRecord::Base.connection.adapter_name == 'Mysql2'
if order == :natural
query = connection.quote(query.to_s)
if type == :boolean
query = connection.quote(query.to_s + "*")
# Query is done as a boolean full-text search. More info here: https://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html
nids = Revision.select("node_revisions.nid, node_revisions.body, node_revisions.title, MATCH(node_revisions.body, node_revisions.title) AGAINST(#{query} IN BOOLEAN MODE) AS score")
.where("MATCH(node_revisions.body, node_revisions.title) AGAINST(#{query} IN BOOLEAN MODE)")
.limit(limit)
.distinct
.collect(&:nid)
else
query = connection.quote(query.to_s)
nids = Revision.select("node_revisions.nid, node_revisions.body, node_revisions.title, MATCH(node_revisions.body, node_revisions.title) AGAINST(#{query} IN NATURAL LANGUAGE MODE) AS score")
.where("MATCH(node_revisions.body, node_revisions.title) AGAINST(#{query} IN NATURAL LANGUAGE MODE)")
.limit(limit)
Expand Down

0 comments on commit ba05350

Please sign in to comment.