massiveart / MassiveSearchBundle

MIT License
68 stars 24 forks source link

Mapping for the image-field missing in XmlDriver #84

Closed benbender closed 8 years ago

benbender commented 8 years ago

I'm playing around with this nice bundle and noticed that the image-fields of my search-index were empty even if I defined them. After digging through the code, it seems to me, that the mapping is missing.

With the following additions it works as expected:

diff --git a/Search/Metadata/Driver/XmlDriver.php b/Search/Metadata/Driver/XmlDriver.php
index bfc3f76..0e7f044 100644
--- a/Search/Metadata/Driver/XmlDriver.php
+++ b/Search/Metadata/Driver/XmlDriver.php
@@ -118,6 +118,7 @@ class XmlDriver extends AbstractFileDriver implements DriverInterface
             $indexMetadata->setTitleField($mapping['title']);
             $indexMetadata->setUrlField($mapping['url']);
             $indexMetadata->setDescriptionField($mapping['description']);
+            $indexMetadata->setImageUrlField($mapping['image']);

             foreach ($mapping['fields'] as $fieldName => $fieldData) {
                 $indexMetadata->addFieldMapping($fieldName, $fieldData);
@@ -148,6 +149,9 @@ class XmlDriver extends AbstractFileDriver implements DriverInterface
         $urlField = $this->getMapping($mapping, 'url');
         $indexMapping['url'] = $urlField;

+        $imageField = $this->getMapping($mapping, 'image');
+        $indexMapping['image'] = $imageField;
+
         $descriptionField = $this->getMapping($mapping, 'description');
         $indexMapping['description'] = $descriptionField;

Am I missing something or is this feature really missing in current master?

wachterjohannes commented 8 years ago

@dantleech do you have any idea why the image isnt there any more?

dantleech commented 8 years ago

According to the changelog support was not added to the XML driver (we use the images feature with a Sulu specific driver).

I am not sure why it was not implemented as it would seem quite trivial. @benbender do you want to make a PR?

benbender commented 8 years ago

Yepp, I can prepare a PR early next week. Just wanted to be sure that I didn't miss something (again *g).

wachterjohannes commented 8 years ago

it seems for me also quite easy and straight forward (: would be really cool if you create a PR for that. Can i ask on which project you work?

benbender commented 8 years ago

Fixed by #86. Can be closed.