Sha256: d18c72fe5ce0a3b6c6930c8eca631a3d30b01085e3d707008efd3fc1b586b39c

Contents?: true

Size: 1.64 KB

Versions: 2

Compression:

Stored size: 1.64 KB

Contents

module Tagliani
  class Configuration
    class Schema < Struct.new(:default)
      def initialize
        self.default = whiteseparated_tags
      end

      private

      def analysis_settings
        {
          analysis: {
            analyzer: {
              gossipAnalyzer: {
                type: 'custom',
                tokenizer: 'whitespace',
                char_filter: %w[dot_remover coma_separator],
                filter: ['lowercase']
              }
            },
            char_filter: {
              dot_remover: {
                type: 'pattern_replace',
                pattern: '\.',
                replacement: ''
              },
              coma_separator: {
                type: 'pattern_replace',
                pattern: '\,',
                replacement: ' '
              }
            }
          }
        }
      end

      def whiteseparated_tags
        {
          settings: analysis_settings,
          mappings: {
            doc: {
              properties: {
                query: { type: 'percolator' },
                object_kls: {
                  type: 'keyword',
                  index: true
                },
                object_id: { type: 'integer' },
                created_at: { type: 'date', format: 'yyyy-MM-dd HH:mm:ss' },
                updated_at: { type: 'date', format: 'yyyy-MM-dd HH:mm:ss' },
                tag_id: { type: 'integer' },
                tag_kls: { type: 'keyword', index: true },
                tag_name: {
                  type: 'text',
                  analyzer: 'gossipAnalyzer'
                }
              }
            }
          }
        }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tagliani-0.1.1 lib/tagliani/configuration/schema.rb
tagliani-0.1.0 lib/tagliani/configuration/schema.rb