File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -140,11 +140,16 @@ public function info()
140140
141141 /**
142142 * @param $id
143+ * @param bool $deleteDocument
143144 * @return bool
144145 */
145- public function delete ($ id )
146+ public function delete ($ id, $ deleteDocument = false )
146147 {
147- return boolval ($ this ->rawCommand ('FT.DEL ' , [$ this ->getIndexName (), $ id ]));
148+ $ arguments = [$ this ->getIndexName (), $ id ];
149+ if ($ deleteDocument ) {
150+ $ arguments [] = 'DD ' ;
151+ }
152+ return boolval ($ this ->rawCommand ('FT.DEL ' , $ arguments ));
148153 }
149154
150155 /**
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ interface IndexInterface extends BuilderInterface
1111 public function create ();
1212 public function drop ();
1313 public function info ();
14- public function delete ($ id );
14+ public function delete ($ id, $ deleteDocument = false );
1515 public function makeDocument ($ id = null ): DocumentInterface ;
1616 public function makeAggregateBuilder (): AggregateBuilderInterface ;
1717 public function getRedisClient (): RediSearchRedisClient ;
Original file line number Diff line number Diff line change @@ -94,6 +94,23 @@ public function testShouldDeleteDocumentById()
9494 $ this ->assertEmpty ($ this ->subject ->search ('My New Book ' )->getDocuments ());
9595 }
9696
97+ public function testShouldPhysicallyDeleteDocumentById ()
98+ {
99+ $ this ->subject ->create ();
100+ $ expectedId = 'fio4oihfohsdfl ' ;
101+ $ document = $ this ->subject ->makeDocument ($ expectedId );
102+ $ document ->title ->setValue ('My New Book ' );
103+ $ document ->author ->setValue ('Jack ' );
104+ $ document ->price ->setValue (123 );
105+ $ document ->stock ->setValue (1123 );
106+ $ this ->subject ->add ($ document );
107+
108+ $ result = $ this ->subject ->delete ($ expectedId , true );
109+
110+ $ this ->assertTrue ($ result );
111+ $ this ->assertEmpty ($ this ->subject ->search ('My New Book ' )->getDocuments ());
112+ }
113+
97114 public function testCreateIndexWithSortableFields ()
98115 {
99116 $ indexName = 'IndexWithSortableFieldsTest ' ;
You can’t perform that action at this time.
0 commit comments