|
@@ 101-141 (lines=41) @@
|
| 98 |
|
/** |
| 99 |
|
* @group functional |
| 100 |
|
*/ |
| 101 |
|
public function testAttachmentAddPdfFileContent(): void |
| 102 |
|
{ |
| 103 |
|
$attachment = new AttachmentProcessor('data'); |
| 104 |
|
$pipeline = $this->_createPipeline('my_custom_pipeline_attachment', 'pipeline for Attachment'); |
| 105 |
|
$pipeline->addProcessor($attachment); |
| 106 |
|
$pipeline->create(); |
| 107 |
|
|
| 108 |
|
$index = $this->_createIndex(); |
| 109 |
|
|
| 110 |
|
$bulk = new Bulk($index->getClient()); |
| 111 |
|
$bulk->setIndex($index); |
| 112 |
|
|
| 113 |
|
$doc1 = new Document(null); |
| 114 |
|
$doc1->addFile('data', __DIR__.'/../data/test.pdf'); |
| 115 |
|
$doc1->set('text', 'basel world'); |
| 116 |
|
|
| 117 |
|
$doc2 = new Document(2, ['data' => '', 'text' => 'test running in basel']); |
| 118 |
|
$doc2->set('text', 'running in basel'); |
| 119 |
|
|
| 120 |
|
$bulk->addDocuments([ |
| 121 |
|
$doc1, $doc2, |
| 122 |
|
]); |
| 123 |
|
$bulk->setRequestParam('pipeline', 'my_custom_pipeline_attachment'); |
| 124 |
|
|
| 125 |
|
$bulk->send(); |
| 126 |
|
$index->refresh(); |
| 127 |
|
|
| 128 |
|
$resultSet = $index->search('xodoa'); |
| 129 |
|
$this->assertEquals(1, $resultSet->count()); |
| 130 |
|
|
| 131 |
|
$resultSet = $index->search('basel'); |
| 132 |
|
$this->assertEquals(2, $resultSet->count()); |
| 133 |
|
|
| 134 |
|
// Author is ruflin |
| 135 |
|
$resultSet = $index->search('ruflin'); |
| 136 |
|
$this->assertEquals(1, $resultSet->count()); |
| 137 |
|
|
| 138 |
|
// String does not exist in file |
| 139 |
|
$resultSet = $index->search('guschti'); |
| 140 |
|
$this->assertEquals(0, $resultSet->count()); |
| 141 |
|
} |
| 142 |
|
|
| 143 |
|
/** |
| 144 |
|
* @group functional |
|
@@ 146-184 (lines=39) @@
|
| 143 |
|
/** |
| 144 |
|
* @group functional |
| 145 |
|
*/ |
| 146 |
|
public function testAddWordxFile(): void |
| 147 |
|
{ |
| 148 |
|
$attachment = new AttachmentProcessor('data'); |
| 149 |
|
$pipeline = $this->_createPipeline('my_custom_pipeline_attachment', 'pipeline for Attachment'); |
| 150 |
|
$pipeline->addProcessor($attachment); |
| 151 |
|
$pipeline->create(); |
| 152 |
|
|
| 153 |
|
$index = $this->_createIndex(); |
| 154 |
|
|
| 155 |
|
$bulk = new Bulk($index->getClient()); |
| 156 |
|
$bulk->setIndex($index); |
| 157 |
|
|
| 158 |
|
$doc1 = new Document(null); |
| 159 |
|
$doc1->addFile('data', __DIR__.'/../data/test.docx'); |
| 160 |
|
$doc1->set('text', 'basel world'); |
| 161 |
|
|
| 162 |
|
$doc2 = new Document(2, ['data' => '', 'text' => 'test running in basel']); |
| 163 |
|
|
| 164 |
|
$bulk->addDocuments([ |
| 165 |
|
$doc1, $doc2, |
| 166 |
|
]); |
| 167 |
|
$bulk->setRequestParam('pipeline', 'my_custom_pipeline_attachment'); |
| 168 |
|
|
| 169 |
|
$bulk->send(); |
| 170 |
|
$index->refresh(); |
| 171 |
|
|
| 172 |
|
$resultSet = $index->search('basel'); |
| 173 |
|
$this->assertEquals(2, $resultSet->count()); |
| 174 |
|
|
| 175 |
|
$resultSet = $index->search('ruflin'); |
| 176 |
|
$this->assertEquals(0, $resultSet->count()); |
| 177 |
|
|
| 178 |
|
$resultSet = $index->search('Xodoa'); |
| 179 |
|
$this->assertEquals(1, $resultSet->count()); |
| 180 |
|
|
| 181 |
|
// String does not exist in file |
| 182 |
|
$resultSet = $index->search('guschti'); |
| 183 |
|
$this->assertEquals(0, $resultSet->count()); |
| 184 |
|
} |
| 185 |
|
|
| 186 |
|
/** |
| 187 |
|
* @group functional |