File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 11import { ElasticClient } from '../elastic-client'
22import 'isomorphic-fetch'
3+
34describe ( 'elastic-client' , ( ) => {
45 it ( 'should create and delete elastic index' , async ( ) => {
56 const client = new ElasticClient ( { hosts : [ 'http://localhost:9200' ] } )
@@ -129,6 +130,37 @@ describe('elastic-client', () => {
129130 expect ( result . code ) . toBe ( 200 )
130131 } )
131132
133+ it ( 'should delete document' , async ( ) => {
134+ const client = new ElasticClient ( { hosts : [ 'http://localhost:9200' ] } )
135+
136+ await client . index ( {
137+ index : 'hello-world2' ,
138+ document : { hello : true } ,
139+ id : '21' ,
140+ } )
141+
142+ await client . refreshIndex ( { index : 'hello-world2' } )
143+ await client . deleteByQuery ( {
144+ index : 'hello-world2' ,
145+ query : {
146+ match : {
147+ hello : true ,
148+ } ,
149+ } ,
150+ } )
151+ await client . refreshIndex ( { index : 'hello-world2' } )
152+ const search = await client . search ( {
153+ index : 'hello-world2' ,
154+ query : {
155+ match : {
156+ hello : true ,
157+ } ,
158+ } ,
159+ } )
160+
161+ expect ( search . data . hits . hits . length ) . toBe ( 0 )
162+ } )
163+
132164 it ( 'should bulk index' , async ( ) => {
133165 const client = new ElasticClient ( { hosts : [ 'http://localhost:9200' ] } )
134166 const result = await client . bulk ( {
Original file line number Diff line number Diff line change @@ -333,7 +333,7 @@ export class ElasticClient {
333333 }
334334
335335 async deleteByQuery ( params : DeleteByQueryRequest ) : Promise < Response < DeleteByQueryResponse > > {
336- let url = `/${ params . index } _delete_by_query`
336+ let url = `/${ params . index } / _delete_by_query`
337337
338338 const queryParams = queryParametersGenerator (
339339 {
You can’t perform that action at this time.
0 commit comments