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

ES: all comments addressed

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