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).
-
#filters(scope:, query: nil, filters: {}) ⇒ FiltersResult
Compute filter facets, sort options, and total count for the given scope.
-
#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 and paginate products.
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.
71 72 73 |
# File 'app/models/spree/search_provider/base.rb', line 71 def ensure_index_settings! # no-op by default end |
#filters(scope:, query: nil, filters: {}) ⇒ FiltersResult
Compute filter facets, sort options, and total count for the given scope. Called by the dedicated filters endpoint — kept separate from search_and_filter to avoid expensive facet queries on every product listing.
37 38 39 |
# File 'app/models/spree/search_provider/base.rb', line 37 def filters(scope:, query: nil, filters: {}) raise NotImplementedError end |
#index(product) ⇒ Object
Index a product — called after product save. No-op for database provider.
44 45 46 |
# File 'app/models/spree/search_provider/base.rb', line 44 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.
65 66 67 |
# File 'app/models/spree/search_provider/base.rb', line 65 def index_batch(documents) # no-op by default end |
#reindex(scope = nil) ⇒ Object
Bulk reindex — full catalog sync. Called manually or via rake task.
78 79 80 |
# File 'app/models/spree/search_provider/base.rb', line 78 def reindex(scope = nil) # no-op by default end |
#remove(product) ⇒ Object
Remove a product from the index.
51 52 53 |
# File 'app/models/spree/search_provider/base.rb', line 51 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).
58 59 60 |
# File 'app/models/spree/search_provider/base.rb', line 58 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 and paginate products. Does NOT compute filter facets — use #filters for that.
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 |