Commit 9c42e1d1 authored by Valery Sizov's avatar Valery Sizov

ES: all comments addressed

parent ad2b85c4
...@@ -4,7 +4,10 @@ module ApplicationSearch ...@@ -4,7 +4,10 @@ module ApplicationSearch
included do included do
include Elasticsearch::Model include Elasticsearch::Model
self.__elasticsearch__.client = Elasticsearch::Client.new host: Gitlab.config.elasticsearch.host, port: Gitlab.config.elasticsearch.port self.__elasticsearch__.client = Elasticsearch::Client.new(
host: Gitlab.config.elasticsearch.host,
port: Gitlab.config.elasticsearch.port
)
index_name [Rails.application.class.parent_name.downcase, self.name.downcase, Rails.env].join('-') index_name [Rails.application.class.parent_name.downcase, self.name.downcase, Rails.env].join('-')
......
...@@ -49,20 +49,13 @@ module MergeRequestsSearch ...@@ -49,20 +49,13 @@ module MergeRequestsSearch
if options[:projects_ids] if options[:projects_ids]
query_hash[:query][:filtered][:filter] = { query_hash[:query][:filtered][:filter] = {
and: [{ and: [
or: [ {
{ terms: {
terms: { target_project_id: [options[:projects_ids]].flatten
source_project_id: [options[:projects_ids]].flatten
}
},
{
terms: {
target_project_id: [options[:projects_ids]].flatten
}
} }
] }
}] ]
} }
end end
......
...@@ -4,7 +4,10 @@ module RepositoriesSearch ...@@ -4,7 +4,10 @@ module RepositoriesSearch
included do included do
include Elasticsearch::Git::Repository include Elasticsearch::Git::Repository
self.__elasticsearch__.client = Elasticsearch::Client.new host: Gitlab.config.elasticsearch.host, port: Gitlab.config.elasticsearch.port self.__elasticsearch__.client = Elasticsearch::Client.new(
host: Gitlab.config.elasticsearch.host,
port: Gitlab.config.elasticsearch.port
)
def repository_id def repository_id
project.id project.id
......
...@@ -4,7 +4,10 @@ module WikiRepositoriesSearch ...@@ -4,7 +4,10 @@ module WikiRepositoriesSearch
included do included do
include Elasticsearch::Git::Repository include Elasticsearch::Git::Repository
self.__elasticsearch__.client = Elasticsearch::Client.new host: Gitlab.config.elasticsearch.host, port: Gitlab.config.elasticsearch.port self.__elasticsearch__.client = Elasticsearch::Client.new(
host: Gitlab.config.elasticsearch.host,
port: Gitlab.config.elasticsearch.port
)
def repository_id def repository_id
"wiki_#{project.id}" "wiki_#{project.id}"
......
...@@ -41,6 +41,7 @@ class Issue < ActiveRecord::Base ...@@ -41,6 +41,7 @@ class Issue < ActiveRecord::Base
scope :cared, ->(user) { where(assignee_id: user) } scope :cared, ->(user) { where(assignee_id: user) }
scope :open_for, ->(user) { opened.assigned_to(user) } scope :open_for, ->(user) { opened.assigned_to(user) }
scope :in_projects, ->(project_ids) { where(project_id: project_ids) }
state_machine :state, initial: :opened do state_machine :state, initial: :opened do
event :close do event :close do
......
...@@ -944,7 +944,7 @@ class Project < ActiveRecord::Base ...@@ -944,7 +944,7 @@ class Project < ActiveRecord::Base
end end
def wiki def wiki
ProjectWiki.new(self, self.owner) @wiki ||= ProjectWiki.new(self, self.owner)
end end
def reference_issue_tracker? def reference_issue_tracker?
......
...@@ -38,8 +38,6 @@ Elasticsearch is a flexible, scalable and powerful search service. It will keep ...@@ -38,8 +38,6 @@ Elasticsearch is a flexible, scalable and powerful search service. It will keep
For installation from source: For installation from source:
For GitHub.com:
``` ```
elasticsearch: elasticsearch:
enabled: true enabled: true
......
...@@ -56,6 +56,7 @@ module Gitlab ...@@ -56,6 +56,7 @@ module Gitlab
if project.empty_repo? || query.blank? if project.empty_repo? || query.blank?
Kaminari.paginate_array([]) Kaminari.paginate_array([])
else else
# We use elastic for default branch only
if root_ref? if root_ref?
project.repository.search( project.repository.search(
query, query,
...@@ -94,6 +95,7 @@ module Gitlab ...@@ -94,6 +95,7 @@ module Gitlab
if project.empty_repo? || query.blank? if project.empty_repo? || query.blank?
Kaminari.paginate_array([]) Kaminari.paginate_array([])
else else
# We use elastic for default branch only
if root_ref? if root_ref?
project.repository.find_commits_by_message_with_elastic(query) project.repository.find_commits_by_message_with_elastic(query)
else else
......
...@@ -67,7 +67,7 @@ module Gitlab ...@@ -67,7 +67,7 @@ module Gitlab
} }
if query =~ /#(\d+)\z/ if query =~ /#(\d+)\z/
Issue.where(project_id: limit_project_ids).where(iid: $1) Issue.in_projects(limit_project_ids).where(iid: $1)
else else
Issue.elastic_search(query, options: opt) Issue.elastic_search(query, options: opt)
end end
......
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