-
Notifications
You must be signed in to change notification settings - Fork 1.5k
DOCSP-46230: atlas search index mgmt #3270
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
Changes from 10 commits
034c6e8
532172c
77d77f5
0f50065
7efe5b1
95ea7e0
85fb2c9
d1c2cfe
1b87a67
2104ca7
b478ece
bd1463c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Support\Facades\Schema; | ||
use MongoDB\Laravel\Schema\Blueprint; | ||
|
||
return new class extends Migration | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the migration class is not actually displayed in the docs, you can move code snippets in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done! |
||
{ | ||
protected $connection = 'mongodb'; | ||
|
||
public function up(): void | ||
{ | ||
// begin-create-search-indexes | ||
Schema::create('galaxies', function (Blueprint $collection) { | ||
$collection->searchIndex([ | ||
'mappings' => [ | ||
'dynamic' => true, | ||
], | ||
], 'dynamic_index'); | ||
$collection->searchIndex([ | ||
'mappings' => [ | ||
'fields' => [ | ||
'name' => [ | ||
['type' => 'string', 'analyzer' => 'lucene.english'], | ||
['type' => 'autocomplete', 'analyzer' => 'lucene.english'], | ||
['type' => 'token'], | ||
], | ||
], | ||
], | ||
], 'auto_index'); | ||
}); | ||
// end-create-search-indexes | ||
|
||
// begin-create-vs-index | ||
Schema::create('galaxies', function (Blueprint $collection) { | ||
$collection->vectorSearchIndex([ | ||
'fields' => [ | ||
[ | ||
'type' => 'vector', | ||
'numDimensions' => 4, | ||
'path' => 'embeddings', | ||
'similarity' => 'cosine', | ||
], | ||
], | ||
], 'vs_index'); | ||
}); | ||
// end-create-vs-index | ||
} | ||
|
||
public function down(): void | ||
{ | ||
// begin-drop-search-index | ||
Schema::table('galaxies', function (Blueprint $collection) { | ||
$collection->dropSearchIndex('auto_index'); | ||
}); | ||
// end-drop-search-index | ||
} | ||
}; |
Uh oh!
There was an error while loading. Please reload this page.