-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Instantsearch] Scout indexing products & categories #734
Conversation
$this->line('Store: ' . $store['name']); | ||
|
||
foreach ($types as $type => $model) { | ||
config()->set('rapidez.index', $type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to infer this from the model itself? It would save us from setting this value which thanks to your changes doesn't seem needed anymore.
Perhaps a function that reads from an empty model variable/constant, which if it's not set Str::snake() on the class name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's also an option; currently we do this differently on multiple places, for example:
- The category index is defined here: https://github.com/rapidez/core/pull/735/files#diff-694b39ded25e81aa9cfa9de2b404533c0f924a4919b0f68b38aebfb0741ff68fR1 which is using this config: https://github.com/rapidez/core/pull/735/files#diff-fe38fec1955243f9e20c1cdc08b64167096d11ee224c3c86fc8e4f4671750a51R64
- For the products we've this: https://github.com/rapidez/core/pull/706/files#diff-b30cee12bf5e6816f22522e4ab112a4dc162789811fdcd04c7df321dcb438dbbR132 which can be used in the frontend with
config.index
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to infer this from the model itself? It would save us from setting this value which thanks to your changes doesn't seem needed anymore.
Perhaps a function that reads from an empty model variable/constant, which if it's not set Str::snake() on the class name
I had done this originally, but figured we might want to keep flexibility up for now, and it might not work properly if you overwrite a model with a different class name (e.g. if your code standards require you to call your extended version of a product model ProductExt
or whatever).
There's also the thing where it checks if you tried to use Scout directly. Although we'd probably be better off using a different solution for that eventually.
Requires this patch for the products to index properly. Without it, only the first 500 products get indexed.
This PR introduces a generic version of the
Searchable
trait that we can put onto any Eloquent model to make it indexable by Scout, as well as some generic functions that can be hooked into to filter/query the data to your liking. This also replaces the indexer commands with one genericIndexCommand
.A few notes:
indexer.php
config file underextra_models
. Is this the best way to go?makeAllSearchableUsing()
might be better if we call a new function inside it called something likesearchableQuery()
maxPositions
andcategories
variables for the Product model into Cache with thearray
driver. There may be a cleaner way to do this.withCategories
function can probably be refactored?Category
model had a weird custom primary key name set which broke Scout. I couldn't find anything that this was actually used for, so I restored it back to what it should be.getConfig()
function. I'm not sure if this is the best way to do this.