Sha256: 707c8b447373d6e6bbaaa9a46bb4aa25b4a34edf97875f088320efc0c51317a9

Contents?: true

Size: 931 Bytes

Versions: 1

Compression:

Stored size: 931 Bytes

Contents

module Spree
  class Order
    module Indexable
      extend ActiveSupport::Concern

      ELASTICSEARCH_SETTINGS = {
        analysis: {
          analyzer: {
            keyword_lowercase: {
              tokenizer: 'keyword',
              filter: ['lowercase']
            }
          }
        }
      }

      included do
        include Spree::Indexable

        ##
        # Define Order mapping for Elasticserach index
        #
        settings ELASTICSEARCH_SETTINGS do
          mappings dynamic: false do
            indexes :product_ids, type: 'integer'
            indexes :created_at, type: 'date'
            indexes :completed_at, type: 'date'
          end
        end

        ##
        # Formats hash for elasticsearch.
        #
        def as_indexed_json(_options = {})
          as_json only: [:created_at, :completed_at],
                  methods: [:product_ids]
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_recommendations-0.0.1 app/models/concerns/spree/order/indexable.rb