Comments (8)
The way I did it is :
php artisan make:command IndexModel
Make sure you register your command in kernel.
in it, changed protected $signature = 'command:ImportModelToES {min}';
The handle method looks like this :
public function handle()
{
$min = $this->argument('min');
$max = $min+5000; //batch size
$this->processModel($min, $max);
$min = $min+5000; // these must match
$this->info(memory_get_usage());
unset($max);
$this->call('command:ImportModelToES', ['min' => $min]);
}
protected function processModel($min, $max)
{
$models = Model::where('id', '>', $min)->where('id', '<=', $max)->get();
Plastic::persist()->bulkSave($models);
$this->info("Indexed to ES from {min} to {max}.");
}
Then you just call php artisan command:ImportModelToES 1
. I did it this way because of my requirements but there are more elegant ways to it. Look at chunk
in laravel documentation
from plastic.
You can create and delete indexes as follows
Plastic::getClient()->indices()->delete(['index' => Plastic::getDefaultIndex()]);
Plastic::getClient()->indices()->create(['index' => Plastic::getDefaultIndex()]);
added this section to documentation ...
from plastic.
And what about creating of indeсes?
from plastic.
Is it required to create index manually or how to create index "on fly" if it does not exist?
from plastic.
I would suggest you create the indices manually, as you can specify the shards, replicas or other settings.
You can use https://github.com/royrusso/elasticsearch-HQ to create indices or https://github.com/lmenezes/elasticsearch-kopf
My information might not be accurate, it's jut how I do it. You can wait for a response from sleimanx2 for certainty.
from plastic.
Already use elasticsearch-HQ but how you see this in production?
In production usually needs to create some kinds of deployment commands, no possibility to use GUI and I'm really hate to use different stupid scripts to do this important things
from plastic.
You just create the index on your production server ( with HQ or command), you do it once anyway. You specify the index in your plastic.php file, and that's it. No more configurations.
from plastic.
Thanks a lot. I think that need to add this code examples into readme
from plastic.
Related Issues (20)
- Nested query fails. Issue with Mapping?
- How to sync a property of a many-to-many relation (using a pivot table)?
- "Nothing to map" message but mappings exist HOT 1
- Can't populate the index with correct data HOT 1
- Update set id to 0 in elasticsearch HOT 1
- Populate and run mappings from json
- There is no good way to set custom model fillers
- Search on Translatable model HOT 1
- Compatibility and status of project HOT 3
- Feature request: Set search parameters for a query HOT 1
- return api response
- phrase_match with Plastic HOT 1
- plastic:populate does not include deleted records
- Consider this package unmaintained HOT 5
- Default $current for paginator in v0.3.1
- IAM - Signed Requests using Plastic
- Make plastic compatible with Laravel 5.7 HOT 5
- Is this project abandoned? HOT 1
- [ErrorException] filter_var(): explicit use of FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED is deprecated HOT 3
- How do I know actual search lucene query while using this library?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plastic.