Skip to content

Commit

Permalink
Added entityType field
Browse files Browse the repository at this point in the history
  • Loading branch information
Viburnum committed Apr 11, 2017
1 parent 35848d2 commit ed6e4b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Model/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
use StingerSoft\EntitySearchBundle\Model\DocumentAdapter;
use Solarium\QueryType\Select\Result\DocumentInterface;

class Document extends DocumentAdapter{


class Document extends DocumentAdapter {

public static function createFromSolariumResult(DocumentInterface $solrDocument) {
$document = new Document();
foreach($solrDocument->getFields() as $key => $value) {
$document->addField($key, $value);
}
$document->setEntityType($document->getFieldValue('entityType'));
$document->setEntityClass($document->getFieldValue('clazz'));
$document->setEntityId($document->getFieldValue('internalId'));
return $document;
Expand Down
5 changes: 3 additions & 2 deletions Services/SearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public function saveDocument(\StingerSoft\EntitySearchBundle\Model\Document $doc
$doc->id = $this->createIdFromDocument($document);
$doc->internalId = json_encode($document->getEntityId());
$doc->clazz = $document->getEntityClass();
$doc->entityType = $document->getEntityType();

foreach($document->getFields() as $key => $value) {
$doc->setField($key, $value);
Expand Down Expand Up @@ -260,10 +261,10 @@ public function getIndexSize() {
}

protected function escapeFacetKey($facetKey) {
return $facetKey == Document::FIELD_TYPE ? 'clazz' : $facetKey;
return $facetKey == Document::FIELD_TYPE ? 'entityType' : $facetKey;
}

protected function unescapeFacetKey($facetKey) {
return $facetKey == 'clazz' ? Document::FIELD_TYPE : $facetKey;
return $facetKey == 'entityType' ? Document::FIELD_TYPE : $facetKey;
}
}

0 comments on commit ed6e4b5

Please sign in to comment.