تكامل قناة Sonic لـ Node. يتم استخدامه مع Sonic، واجهة البحث الخلفية السريعة والخفيفة والخالية من المخططات.
تتيح لك قناة Sonic إدارة فهرس بحث Sonic الخاص بك، من كود NodeJS الخاص بك. قم بالاستعلام عن الفهرس الخاص بك واحصل على نتائج البحث، وادفع الإدخالات إلى الفهرس الخاص بك ثم قم بإخراجها برمجيًا.
؟؟ صُنع في نانت، فرنسا.
هش |
هل تستخدم قناة صوتية وتريد أن تكون مدرجًا هناك؟ اتصل بي.
قم بتضمين sonic-channel
في تبعيات package.json
الخاصة بك.
وبدلاً من ذلك، يمكنك تشغيل npm install sonic-channel --save
.
يمكن إنشاء node-sonic-channel
في وضع البحث على هذا النحو:
var SonicChannelSearch = require ( "sonic-channel" ) . Search ;
var sonicChannelSearch = new SonicChannelSearch ( {
host : "::1" , // Or '127.0.0.1' if you are still using IPv4
port : 1491 , // Default port is '1491'
auth : "SecretPassword" // Authentication password (if any)
} ) . connect ( {
connected : function ( ) {
// Connected handler
console . info ( "Sonic Channel succeeded to connect to host (search)." ) ;
} ,
disconnected : function ( ) {
// Disconnected handler
console . error ( "Sonic Channel is now disconnected (search)." ) ;
} ,
timeout : function ( ) {
// Timeout handler
console . error ( "Sonic Channel connection timed out (search)." ) ;
} ,
retrying : function ( ) {
// Retry handler
console . error ( "Trying to reconnect to Sonic Channel (search)..." ) ;
} ,
error : function ( error ) {
// Failure handler
console . error ( "Sonic Channel failed to connect to host (search)." , error ) ;
}
} ) ;
استخدم نفس مثيل sonicChannelSearch
للاستعلام عن فهرس البحث:
sonicChannelSearch . query ( "messages" , "default" , "valerian saliou" )
. then ( function ( results ) {
// Query results come there
} )
. catch ( function ( error ) {
// Query errors come there
} ) ;
إذا كنت بحاجة إلى قطع الاتصال المستمر بـ Sonic، فاستخدم:
sonicChannelSearch . close ( )
. then ( function ( ) {
// Close success handler
} )
. catch ( function ( error ) {
// Close errors come there
} ) ;
يمكن إنشاء node-sonic-channel
في وضع الاستيعاب على هذا النحو:
var SonicChannelIngest = require ( "sonic-channel" ) . Ingest ;
var sonicChannelIngest = new SonicChannelIngest ( {
host : "::1" , // Or '127.0.0.1' if you are still using IPv4
port : 1491 , // Default port is '1491'
auth : "SecretPassword" // Authentication password (if any)
} ) . connect ( {
connected : function ( ) {
// Connected handler
console . info ( "Sonic Channel succeeded to connect to host (ingest)." ) ;
} ,
disconnected : function ( ) {
// Disconnected handler
console . error ( "Sonic Channel is now disconnected (ingest)." ) ;
} ,
timeout : function ( ) {
// Timeout handler
console . error ( "Sonic Channel connection timed out (ingest)." ) ;
} ,
retrying : function ( ) {
// Retry handler
console . error ( "Trying to reconnect to Sonic Channel (ingest)..." ) ;
} ,
error : function ( error ) {
// Failure handler
console . error ( "Sonic Channel failed to connect to host (ingest)." , error ) ;
}
} ) ;
استخدم نفس مثيل sonicChannelIngest
لدفع النص إلى فهرس البحث:
sonicChannelIngest . push ( "messages" , "default" , "conversation:1" , "I met Valerian Saliou yesterday. Great fun!" )
. then ( function ( ) {
// Push success handler
} )
. catch ( function ( error ) {
// Push errors come there
} ) ;
إذا كنت بحاجة إلى قطع الاتصال المستمر بـ Sonic، فاستخدم:
sonicChannelIngest . close ( )
. then ( function ( ) {
// Close success handler
} )
. catch ( function ( error ) {
// Close errors come there
} ) ;
يمكن إنشاء node-sonic-channel
في وضع التحكم على هذا النحو:
var SonicChannelControl = require ( "sonic-channel" ) . Control ;
var sonicChannelControl = new SonicChannelControl ( {
host : "::1" , // Or '127.0.0.1' if you are still using IPv4
port : 1491 , // Default port is '1491'
auth : "SecretPassword" // Authentication password (if any)
} ) . connect ( {
connected : function ( ) {
// Connected handler
console . info ( "Sonic Channel succeeded to connect to host (control)." ) ;
} ,
disconnected : function ( ) {
// Disconnected handler
console . error ( "Sonic Channel is now disconnected (control)." ) ;
} ,
timeout : function ( ) {
// Timeout handler
console . error ( "Sonic Channel connection timed out (control)." ) ;
} ,
retrying : function ( ) {
// Retry handler
console . error ( "Trying to reconnect to Sonic Channel (control)..." ) ;
} ,
error : function ( error ) {
// Failure handler
console . error ( "Sonic Channel failed to connect to host (control)." , error ) ;
}
} ) ;
يمكنك استخدام نفس مثيل sonicChannelControl
لإدارة خادم Sonic الخاص بك.
إذا كنت بحاجة إلى قطع الاتصال المستمر بـ Sonic، فاستخدم:
sonicChannelControl . close ( )
. then ( function ( ) {
// Close success handler
} )
. catch ( function ( error ) {
// Close errors come there
} ) ;
للحصول على تفاصيل حول قيم الوسيطات، راجع مواصفات بروتوكول قناة Sonic.
sonicChannelSearch.query(collection_id<string>, bucket_id<string>, terms_text<string>, [options{limit<number>, offset<number>, lang<string>}<object>]?)
➡️ Promise(results<object>, error<object>)
sonicChannelSearch.suggest(collection_id<string>, bucket_id<string>, word_text<string>, [options{limit<number>}<object>]?)
➡️ Promise(results<object>, error<object>)
sonicChannelSearch.list(collection_id<string>, bucket_id<string>, [options{limit<number>, offset<number>}<object>]?)
➡️ Promise(results<object>, error<object>)
sonicChannelIngest.push(collection_id<string>, bucket_id<string>, object_id<string>, text<string>, [options{lang<string>}<object>]?)
➡️ Promise(_, error<object>)
sonicChannelIngest.pop(collection_id<string>, bucket_id<string>, object_id<string>, text<string>)
➡️ Promise(count<number>, error<object>)
sonicChannelIngest.count<number>(collection_id<string>, [bucket_id<string>]?, [object_id<string>]?)
➡️ Promise(count<number>, error<object>)
sonicChannelIngest.flushc(collection_id<string>)
➡️ Promise(count<number>, error<object>)
sonicChannelIngest.flushb(collection_id<string>, bucket_id<string>)
➡️ Promise(count<number>, error<object>)
sonicChannelIngest.flusho(collection_id<string>, bucket_id<string>, object_id<string>)
➡️ Promise(count<number>, error<object>)
sonicChannelControl.trigger(action<string>, [data<string>]?)
➡️ Promise(_, error<object>)
sonicChannelControl.info()
➡️ Promise(results<object>, error<object>)
أتساءل ما هو سونيك؟ تحقق من فاليريانساليو/سونيك .
تحتفظ node-sonic-channel
باتصالات TCP المستمرة بواجهات شبكة Sonic التي تستمع إلى مثيل Sonic قيد التشغيل. في حالة فصل node-sonic-channel
عن Sonic، ستتم إعادة محاولة الاتصال بمجرد إنشاء الاتصال مرة أخرى.
يمكنك تكوين تفاصيل الاتصال لمثيل Sonic الخاص بك عند تهيئة node-sonic-channel
من التعليمات البرمجية الخاصة بك؛ عبر مضيف ومنفذ Sonic.