Class: Spree::SearchProvider::Base
- Inherits:
-
Object
- Object
- Spree::SearchProvider::Base
- Defined in:
- app/models/spree/search_provider/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Class Method Summary collapse
-
.indexing_required? ⇒ Boolean
Whether this provider requires background indexing jobs.
Instance Method Summary collapse
-
#ensure_index_settings! ⇒ Object
Configure index settings (filterable, sortable, searchable attributes).
-
#index(product) ⇒ Object
Index a product — called after product save.
-
#index_batch(documents) ⇒ Object
Index a batch of documents.
-
#initialize(store) ⇒ Base
constructor
A new instance of Base.
-
#reindex(scope = nil) ⇒ Object
Bulk reindex — full catalog sync.
-
#remove(product) ⇒ Object
Remove a product from the index.
-
#remove_by_id(prefixed_id) ⇒ Object
Remove a document from the index by prefixed ID (used when record is already deleted).
-
#search_and_filter(scope:, query: nil, filters: {}, sort: nil, page: 1, limit: 25) ⇒ SearchResult
Search, filter, and return facets in one call.
Constructor Details
#initialize(store) ⇒ Base
Returns a new instance of Base.
12 13 14 |
# File 'app/models/spree/search_provider/base.rb', line 12 def initialize(store) @store = store end |
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store.
4 5 6 |
# File 'app/models/spree/search_provider/base.rb', line 4 def store @store end |
Class Method Details
.indexing_required? ⇒ Boolean
Whether this provider requires background indexing jobs. Override in subclasses. Database provider returns false.
8 9 10 |
# File 'app/models/spree/search_provider/base.rb', line 8 def self.indexing_required? false end |
Instance Method Details
#ensure_index_settings! ⇒ Object
Configure index settings (filterable, sortable, searchable attributes). Called by rake task before indexing. No-op for database provider.
59 60 61 |
# File 'app/models/spree/search_provider/base.rb', line 59 def ensure_index_settings! # no-op by default end |
#index(product) ⇒ Object
Index a product — called after product save. No-op for database provider.
32 33 34 |
# File 'app/models/spree/search_provider/base.rb', line 32 def index(product) # no-op by default end |
#index_batch(documents) ⇒ Object
Index a batch of documents. Called by rake task with pre-serialized documents.
53 54 55 |
# File 'app/models/spree/search_provider/base.rb', line 53 def index_batch(documents) # no-op by default end |
#reindex(scope = nil) ⇒ Object
Bulk reindex — full catalog sync. Called manually or via rake task.
66 67 68 |
# File 'app/models/spree/search_provider/base.rb', line 66 def reindex(scope = nil) # no-op by default end |
#remove(product) ⇒ Object
Remove a product from the index.
39 40 41 |
# File 'app/models/spree/search_provider/base.rb', line 39 def remove(product) # no-op by default end |
#remove_by_id(prefixed_id) ⇒ Object
Remove a document from the index by prefixed ID (used when record is already deleted).
46 47 48 |
# File 'app/models/spree/search_provider/base.rb', line 46 def remove_by_id(prefixed_id) # no-op by default end |
#search_and_filter(scope:, query: nil, filters: {}, sort: nil, page: 1, limit: 25) ⇒ SearchResult
Search, filter, and return facets in one call.
25 26 27 |
# File 'app/models/spree/search_provider/base.rb', line 25 def search_and_filter(scope:, query: nil, filters: {}, sort: nil, page: 1, limit: 25) raise NotImplementedError end |