Commit 970a029f authored by Nick Thomas's avatar Nick Thomas

Fix the reference pattern for merge requests in elasticsearch

parent 0d6ec15f
...@@ -147,7 +147,7 @@ module Elastic ...@@ -147,7 +147,7 @@ module Elastic
query_hash query_hash
end end
def iid_query_hash(query_hash, iid) def iid_query_hash(iid)
{ {
query: { query: {
bool: { bool: {
......
...@@ -49,7 +49,7 @@ module Elastic ...@@ -49,7 +49,7 @@ module Elastic
def self.elastic_search(query, options: {}) def self.elastic_search(query, options: {})
query_hash = query_hash =
if query =~ /#(\d+)\z/ if query =~ /#(\d+)\z/
iid_query_hash(query_hash, $1) iid_query_hash($1)
else else
basic_query_hash(%w(title^2 description), query) basic_query_hash(%w(title^2 description), query)
end end
......
...@@ -61,8 +61,8 @@ module Elastic ...@@ -61,8 +61,8 @@ module Elastic
def self.elastic_search(query, options: {}) def self.elastic_search(query, options: {})
query_hash = query_hash =
if query =~ /#(\d+)\z/ if query =~ /\!(\d+)\z/
iid_query_hash(query_hash, $1) iid_query_hash($1)
else else
basic_query_hash(%w(title^2 description), query) basic_query_hash(%w(title^2 description), query)
end end
......
...@@ -28,6 +28,7 @@ describe Issue, elastic: true do ...@@ -28,6 +28,7 @@ describe Issue, elastic: true do
options = { project_ids: [project.id] } options = { project_ids: [project.id] }
expect(described_class.elastic_search('(term1 | term2 | term3) +bla-bla', options: options).total_count).to eq(2) expect(described_class.elastic_search('(term1 | term2 | term3) +bla-bla', options: options).total_count).to eq(2)
expect(described_class.elastic_search(Issue.last.to_reference, options: options).total_count).to eq(1)
end end
it "returns json with all needed elements" do it "returns json with all needed elements" do
......
...@@ -28,6 +28,7 @@ describe MergeRequest, elastic: true do ...@@ -28,6 +28,7 @@ describe MergeRequest, elastic: true do
options = { project_ids: [project.id] } options = { project_ids: [project.id] }
expect(described_class.elastic_search('term1 | term2 | term3', options: options).total_count).to eq(2) expect(described_class.elastic_search('term1 | term2 | term3', options: options).total_count).to eq(2)
expect(described_class.elastic_search(MergeRequest.last.to_reference, options: options).total_count).to eq(1)
end end
it "returns json with all needed elements" do it "returns json with all needed elements" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment