Node.js용 Sonic 채널 통합 빠르고 가볍고 스키마가 없는 검색 백엔드인 Sonic과 함께 사용됩니다.
Sonic 채널을 사용하면 NodeJS 코드에서 Sonic 검색 색인을 관리할 수 있습니다. 인덱스를 쿼리하고 검색 결과를 얻고, 항목을 인덱스에 푸시하고 프로그래밍 방식으로 팝합니다.
?? 프랑스 낭트에서 제작되었습니다.
상쾌한 |
당신은 음파 채널을 사용하고 있고 거기에 나열되기를 원하십니까? 저에게 연락하세요.
package.json
종속성에 sonic-channel
포함합니다.
또는 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 Channel Protocol 사양을 참조하세요.
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>)
소닉(Sonic)이 무엇인지 궁금하시죠? valeriansaliou/sonic을 확인하세요.
node-sonic-channel
실행 중인 Sonic 인스턴스에서 수신 대기 중인 Sonic 네트워크 인터페이스에 대한 지속적인 TCP 연결을 유지합니다. node-sonic-channel
Sonic에서 연결이 끊어진 경우 연결이 다시 설정되면 연결을 다시 시도합니다.
코드에서 node-sonic-channel
초기화할 때 Sonic 인스턴스의 연결 세부 정보를 구성할 수 있습니다. Sonic 호스트 및 포트를 통해.