-
Notifications
You must be signed in to change notification settings - Fork 81
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃殌 Feature: Add Sync with Meilisearch for Dart #188
Comments
can you please assign this to me.. i would love to contribute on this... |
Hi @notpritam have assigned the issue to you! Thank you for showing interest in contributing to Appwrite! Happy Hacktoberfest 馃巸 Notes:
|
Here is the Progress , import 'dart:convert';
import 'dart:io';
import 'utils.dart';
import 'package:http/http.dart' as http;
import 'package:meilisearch/meilisearch.dart';
import 'package:dart_appwrite/dart_appwrite.dart';
Future<void> main(final context) async {
final requiredEnvVars = [
'APPWRITE_API_KEY',
'APPWRITE_DATABASE_ID',
'APPWRITE_COLLECTION_ID',
'MEILISEARCH_ENDPOINT',
'MEILISEARCH_INDEX_NAME',
'MEILISEARCH_ADMIN_API_KEY',
'MEILISEARCH_SEARCH_API_KEY',
];
throwIfMissing(Platform.environment, requiredEnvVars);
if (context.method == 'GET') {
final html = interpolate(await getStaticFile('index.html'), {
'MEILISEARCH_ENDPOINT': Platform.environment['MEILISEARCH_ENDPOINT'] as String,
'MEILISEARCH_INDEX_NAME': Platform.environment['MEILISEARCH_INDEX_NAME'] as String,
'MEILISEARCH_SEARCH_API_KEY':
Platform.environment['MEILISEARCH_SEARCH_API_KEY'] as String,
});
context.req.response
..headers.contentType = ContentType.html
..write(html)
..close();
} else {
final client = Client()
.setEndpoint('https://cloud.appwrite.io/v1')
.setProject(Platform.environment['APPWRITE_FUNCTION_PROJECT_ID'])
.setKey(Platform.environment['APPWRITE_API_KEY']);
final databases = Databases(client);
final meilisearch = MeiliSearchClient('http:https://127.0.0.1:7700', Platform.environment['MEILISEARCH_ADMIN_API_KEY'] as String);
final index = meilisearch.index(Platform.environment['MEILISEARCH_INDEX_NAME'] as String);
String? cursor;
do {
final queries = [Query.limit(100)];
if (cursor != null) {
queries.add(Query.cursorAfter(cursor!));
}
final response = await databases.listDocuments(
databaseId: Platform.environment['APPWRITE_DATABASE_ID'] as String,
collectionId: Platform.environment['APPWRITE_COLLECTION_ID'] as String,
queries: queries,
);
final documents = response['documents'];
if (documents.isNotEmpty) {
cursor = documents[documents.length - 1]['\$id'];
} else {
print('No more documents found.');
cursor = null;
break;
}
print('Syncing chunk of ${documents.length} documents ...');
await index.addDocuments(documents, primaryKey: '\$id');
} while (cursor != null);
print('Sync finished.');
context.req.response
..write('Sync finished.')
..close();
}
}
String interpolate(String content, Map<String, String> variables) {
for (final entry in variables.entries) {
content = content.replaceAll('{{${entry.key}}}', entry.value);
}
return content;
}
|
@notpritam Thanks for the update! |
Hi @notpritam any update? |
Hey @gewenyu99 @Haimantika , can I work on the issue if the previous assignee is inactive? |
I am almost done with issue, i was having some problem with meilisearch, I will create a pr tomorrow after completing it |
Hi, is the issue with Meilisearch solved? If not, you can raise a support thread on our Discord server and we can help you |
Closing issue due to inactivity and hacktoberfest being over, thank you for taking the time to be part of hacktoberfest this year :) |
Appwrite Functions allow you to extend and customize your Appwrite server functionality by executing your custom code. 馃ぉ You can learn more at our official Appwrite Functions docs.
Your task is to implement the Sync with Meilisearch function in Dart. You can look at the existing Appwrite Functions Templates in another coding language.
Your function should behave and be implemented similarly to existing Sync with Meilisearch Node.js template.
Tasks summary:
feat-implement-sync-with-meilisearch-dart
dart/sync_with_meilisearch/
.README.md
explaining what the function does, how to use it, and customize it. Here is an example.If you need any help, contact us on our Discord server.
Are you ready to work on this issue? 馃 Let us know, and we will assign it to you 馃槉
Happy Appwriting!
The text was updated successfully, but these errors were encountered: