/** * @test */ public function verifyKeywordsGetsSetWithFieldEnrichments() { $fixtureEnrichment = new Enrichment(); $fieldEnrichmentLow = new FieldEnrichment(); $fieldEnrichmentLow->setFieldName('lowboostw'); $fieldEnrichmentLow->setContent('low low low'); $fixtureEnrichment->addFieldEnrichment($fieldEnrichmentLow); $fieldEnrichmentNormal = new FieldEnrichment(); $fieldEnrichmentNormal->setFieldName('normalboostw'); $fieldEnrichmentNormal->setContent('normal normal normal'); $fixtureEnrichment->addFieldEnrichment($fieldEnrichmentNormal); $fieldEnrichmentHigh = new FieldEnrichment(); $fieldEnrichmentHigh->setFieldName('highboostw'); $fieldEnrichmentHigh->setContent('high high high'); $fixtureEnrichment->addFieldEnrichment($fieldEnrichmentHigh); $this->enrichment->setLowBoostedKeywords('low low low'); $this->enrichment->setNormalBoostedKeywords('normal normal normal'); $this->enrichment->setHighBoostedKeywords('high high high'); $this->assertEquals($this->enrichment, $fixtureEnrichment); }
/** * Set field enrichment by field name * * @param string $fieldName * @param $value */ protected function setBoostWordsByFieldName($fieldName, $value) { //if we have allready enrichments for this fieldName we remove them //and create a new fieldEnrichment right away if ($this->hasFieldEnrichmentForFieldName($fieldName)) { $this->removeFieldEnrichmentsForFieldName($fieldName); } //when we set the boostword fieldValue to an empty value, we semantically remove the field enrichment $wasFieldReset = trim($value) == ''; if ($wasFieldReset) { return; } $fieldEnrichment = new FieldEnrichment(); $fieldEnrichment->setFieldName($fieldName); $fieldEnrichment->setContent($value); $this->addFieldEnrichment($fieldEnrichment); }