mongodb / laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)
https://www.mongodb.com/compatibility/mongodb-laravel-integration
MIT License
6.99k stars 1.42k forks source link

How to create Text Index? #1489

Closed saeedvz closed 4 years ago

saeedvz commented 6 years ago

How can i create text index in migrations?

Siebov commented 6 years ago

Hey, guys! It's realy good qquestion. How can I run totally raw query? Need something like DB::statement('db.proposals.createIndex( { summary: "text", content: "text", title: "text" } )'); @jenssegers

Siebov commented 6 years ago

@saeedvaziry https://github.com/jenssegers/laravel-mongodb/wiki/Creating-Full-Text-Index-With-Laravel-Migration-Using-Moloquent

Here is the answer)

saeedvz commented 6 years ago

@Sebbba Thanks for your answer. I used this solution to my problem

https://docs.mongodb.com/php-library/current/tutorial/indexes/#create-indexes

tranghaviet commented 5 years ago
Schema::table('provinces', function (Blueprint $table) {
        $table->index(['name' => 'text'], 'name_full_text');
});