Skip to content

Commit

Permalink
#37 Adopts a test that searches the author field so that it uses a we…
Browse files Browse the repository at this point in the history
…ighted search (which searches across all defined fields instead of just the title field)
  • Loading branch information
extracts committed Dec 4, 2023
1 parent 4577fcf commit 9e165b1
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions test/Solr/Solarium/AdapterSearchingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,22 +268,28 @@ public function testSearchWithDiacritics()
$docB->addPersonAuthor($author);
$docB->store();

$index = Service::selectIndexingService(null, 'solr');
$index->addDocumentsToIndex([$docA, $docB]);
$this->indexDocuments([$docA, $docB]);

$search = new Searcher();
$search = Service::selectSearchingService(null, 'solr');
$query = $this->queryWithSearchString($search, 'muller');

$query = new QueryUtil(QueryUtil::SIMPLE);
$query->setCatchAll('muller');
$result = $search->search($query);
$query->setWeightedSearch(true);
$query->setWeightedFields(['author' => 1.0]);

$this->assertEquals(2, $result->getAllMatchesCount());
$result = $search->customSearch($query);
$matchingIds = $result->getReturnedMatchingIds();

$query = new QueryUtil(QueryUtil::SIMPLE);
$query->setCatchAll('müller');
$result = $search->search($query);
$this->assertEquals(2, count($matchingIds));

$this->assertEquals(2, $result->getAllMatchesCount());
$filter = $search->createFilter();
$filter->createSimpleEqualityFilter('*')->addValue('müller');
$query->setFilter($filter);

$result = $search->customSearch($query);
$matchingIds = $result->getReturnedMatchingIds();

// when searching with diacritics, expect the same documents being found
$this->assertEquals(2, count($matchingIds));
}

public function testMapYearFacetIndexFieldsToYearAsset()
Expand Down

0 comments on commit 9e165b1

Please sign in to comment.