diff --git a/README_elasticsearch.md b/README_elasticsearch.md index 60e55760f..96cf0e5a1 100644 --- a/README_elasticsearch.md +++ b/README_elasticsearch.md @@ -17,9 +17,20 @@ * Configure Zammad * rails r "Setting.set('es_url', 'http://172.0.0.1:9200')" - * rails r "Setting.set('es_user', 'elasticsearch')" # optional - * rails r "Setting.set('es_password', 'zammad')" # optional - * rails r "Setting.set('es_index', Socket.gethostname + '_zammad')" # optional + + # optional - es with http basic auth + * rails r "Setting.set('es_user', 'elasticsearch')" + * rails r "Setting.set('es_password', 'zammad')" + + # optional - extra es index name space + * rails r "Setting.set('es_index', Socket.gethostname + '_zammad')" + + # optional - ignore certain file extentions + * rails r "Setting.set('es_attachment_ignore', [ '.png', '.jpg', '.jpeg', '.mpeg', '.mpg', '.mov', '.bin', '.exe', '.box', '.mbox' ] )" + + # optional - max attachment size which is used by es, default is 50 mb + * rails r "Setting.set('es_attachment_max_size_in_mb', 50 )" + * Create elastic search indexes * rake searchindex:rebuild # drop/create/reload diff --git a/app/models/ticket/search_index.rb b/app/models/ticket/search_index.rb index 547a0d8b6..0cad2a46a 100644 --- a/app/models/ticket/search_index.rb +++ b/app/models/ticket/search_index.rb @@ -51,10 +51,10 @@ returns attributes = search_index_attribute_lookup( attributes, ticket ) # list ignored file extentions - attachments_ignore = Setting.set('es_attachment_ignore') || [ '.png', '.jpg', '.jpeg', '.mpeg', '.mpg', '.mov', '.bin', '.exe' ] + attachments_ignore = Setting.get('es_attachment_ignore') || [ '.png', '.jpg', '.jpeg', '.mpeg', '.mpg', '.mov', '.bin', '.exe' ] # max attachment size - attachment_max_size_in_mb = Setting.set('es_attachment_max_size_in_mb') || 40 + attachment_max_size_in_mb = Setting.get('es_attachment_max_size_in_mb') || 40 # collect article data articles = Ticket::Article.where( :ticket_id => self.id ) @@ -84,6 +84,7 @@ returns # check file size if true +# if attachment.content && attachment.content.size / 1024 / 1024 <= attachment_max_size_in_mb # check ignored files if attachment.filename diff --git a/db/migrate/20140128000001_add_search_index.rb b/db/migrate/20140128000001_add_search_index.rb index 6fb854c09..61cc3cb86 100644 --- a/db/migrate/20140128000001_add_search_index.rb +++ b/db/migrate/20140128000001_add_search_index.rb @@ -37,7 +37,7 @@ class AddSearchIndex < ActiveRecord::Migration :name => 'es_attachment_ignore', :area => 'SearchIndex::Elasticsearch', :description => 'Define attachment extentions which are ignored for Elasticsearch.', - :state => [ '.png', '.jpg', '.jpeg', '.mpeg', '.mpg', '.mov', '.bin', '.exe' ], + :state => [ '.png', '.jpg', '.jpeg', '.mpeg', '.mpg', '.mov', '.bin', '.exe', '.box', '.mbox' ], :frontend => false ) Setting.create_or_update( diff --git a/test/integration/elasticsearch_test.rb b/test/integration/elasticsearch_test.rb index 926d0dc71..8ea7d035c 100644 --- a/test/integration/elasticsearch_test.rb +++ b/test/integration/elasticsearch_test.rb @@ -117,9 +117,6 @@ class ElasticsearchTest < ActiveSupport::TestCase ) # simulate upload - - - form_id = '123456789' # add attachments which should get index / .txt @@ -256,7 +253,7 @@ class ElasticsearchTest < ActiveSupport::TestCase # search for indexed attachment result = Ticket.search( :current_user => agent, - :query => '"some normal text"', + :query => 'some AND normal AND text', :limit => 15, ) assert(result[0], 'record 1') @@ -264,7 +261,7 @@ class ElasticsearchTest < ActiveSupport::TestCase result = Ticket.search( :current_user => agent, - :query => '"otrs.org"', + :query => 'otrs.org', :limit => 15, ) assert(result[0], 'record 1') @@ -274,14 +271,14 @@ class ElasticsearchTest < ActiveSupport::TestCase # search for not indexed attachment result = Ticket.search( :current_user => agent, - :query => '"some too big text"', + :query => 'some AND too AND big AND text', :limit => 15, ) assert(!result[0], 'record 1') result = Ticket.search( :current_user => agent, - :query => '"Old programmers never die"', + :query => 'Old AND programmers AND never AND die', :limit => 15, ) assert(!result[0], 'record 1')