Skip to content

Commit

Permalink
Integration 2 (#14)
Browse files Browse the repository at this point in the history
* FIX: Make null fields empty string, otherwise manticoresearch breaks

* FIX: Ensure all fields are converted back to CamelCase

* FIX: Stored fields now a thang

* FIX: Filter highlighted fields

* FIX: Coding standards, debug deletion

* ENHANCEMENT: Multi fields now indexed

* ENHANCEMENT: bigram indexing

* FIX: Has many fields

* WIP: Method name changes
  • Loading branch information
gordonbanderson committed Sep 7, 2020
1 parent 756a5d2 commit bdbe1a1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
3 changes: 0 additions & 3 deletions src/Service/BulkIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

use SilverStripe\ORM\DataObject;
use Suilven\FreeTextSearch\Factory\IndexerFactory;
use Suilven\FreeTextSearch\Helper\IndexingHelper;

/**
* Class BulkIndexer
Expand Down Expand Up @@ -46,8 +45,6 @@ public function setIndex(string $newIndex): void
*/
public function addDataObject(DataObject $dataObject): void
{
$helper = new IndexingHelper();

$factory = new IndexerFactory();
$indexer = $factory->getIndexer();
$indexer->setIndexName($this->index);
Expand Down
7 changes: 6 additions & 1 deletion src/Service/IndexCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public function createIndex(string $indexName): void

$columns = [];
foreach ($fields as $field) {
if ($field === 'Link') {
continue;
}

$fieldType = $specs[$field];

// this will be the most common
Expand Down Expand Up @@ -86,6 +90,7 @@ public function createIndex(string $indexName): void
$indexes = new Indexes();
$index = $indexes->getIndex($indexName);
$mvaFields = $index->getHasManyFields();

error_log(print_r($mvaFields, true));

foreach(array_keys($mvaFields) as $mvaColumnName) {
Expand All @@ -100,7 +105,7 @@ public function createIndex(string $indexName): void
'dict' => 'keywords',
'min_infix_len' => 2,
'html_strip' => 1,
'bigram_index' => 'both_freq'
'bigram_index' => 'all',
];


Expand Down
2 changes: 1 addition & 1 deletion src/Service/Searcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function search(?string $q): SearchResults


$hasManyFields = $index->getHasManyFields();
foreach(array_keys($hasManyFields) as $key) {
foreach (\array_keys($hasManyFields) as $key) {
$allFields[] = $key;
}

Expand Down
3 changes: 1 addition & 2 deletions tests/Service/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ public function testIndexOneDocumentAndSearch(): void
$doc = DataObject::get_by_id(\Page::class, self::$pageID);
$factory = new IndexerFactory();
$indexer = $factory->getIndexer();
$indexer->setIndex('sitetree');
$indexer->setIndexName('sitetree');
$indexer->index($doc);


$searcher = new Searcher();
$searcher->setIndexName('sitetree');

Expand Down

0 comments on commit bdbe1a1

Please sign in to comment.