Merge pull request #711 from AyuntamientoMadrid/search-no-trigram

removes trigram search algorithm
This commit is contained in:
Juanjo Bazán
2015-11-18 21:13:23 +01:00
2 changed files with 6 additions and 21 deletions

View File

@@ -51,9 +51,9 @@ class Proposal < ActiveRecord::Base
tags: :name
},
using: {
tsearch: { dictionary: "spanish", tsvector_column: 'tsv' },
trigram: { threshold: 0.1 },
tsearch: { dictionary: "spanish", tsvector_column: 'tsv' }
},
ignoring: :accents,
ranked_by: '(:tsearch + proposals.cached_votes_up)',
order_within_rank: "proposals.created_at DESC"
}

View File

@@ -388,15 +388,15 @@ describe Proposal do
context "stemming" do
it "searches word stems" do
proposal = create(:proposal, summary: 'limpiar')
proposal = create(:proposal, summary: 'biblioteca')
results = Proposal.search('limpiará')
results = Proposal.search('bibliotecas')
expect(results).to eq([proposal])
results = Proposal.search('limpiémos')
results = Proposal.search('bibliotec')
expect(results).to eq([proposal])
results = Proposal.search('limpió')
results = Proposal.search('biblioteco')
expect(results).to eq([proposal])
end
@@ -432,21 +432,6 @@ describe Proposal do
end
context "typos" do
it "searches with typos" do
proposal = create(:proposal, summary: 'difusión')
results = Proposal.search('difuon')
expect(results).to eq([proposal])
proposal2 = create(:proposal, summary: 'desarrollo')
results = Proposal.search('desarolo')
expect(results).to eq([proposal2])
end
end
context "order" do
it "orders by weight" do