Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexing fails for search fields with role "image" #186

Open
therouv opened this issue Feb 5, 2021 · 1 comment
Open

Indexing fails for search fields with role "image" #186

therouv opened this issue Feb 5, 2021 · 1 comment
Labels
Bug Error or unexpected behavior of already existing functionality

Comments

@therouv
Copy link

therouv commented Feb 5, 2021

We've created a very simple article bundle based on the ContentBundle. So far it works great! Persisting new and existing entities in the database works fine. But indexing an entity fails due to an "array to string conversion".

After some debugging and hints from Alex in Slack, we've found that <tag name="sulu.search.field" role="image"/> seems to be the culprit. Removing this line will result in a successful indexing.

Related note: Using <tag name="sulu.search.field" role="image"/> with a content element on pages works fine.

Expected behavior

Entity is successfully persisted and indexed.

Actual behavior

Entity is successfully persisted in the database but indexing fails with the following exception:

ErrorException: Notice: Array to string conversion in /var/www/html/vendor/handcraftedinthealps/zendsearch/library/ZendSearch/Lucene/Storage/File/AbstractFile.php:341
Stack trace:
#0 /var/www/html/vendor/handcraftedinthealps/zendsearch/library/ZendSearch/Lucene/Index/SegmentWriter/AbstractSegmentWriter.php(229): ZendSearch\\Lucene\\Storage\\File\\AbstractFile->writeString(\'Array\')
#1 /var/www/html/vendor/handcraftedinthealps/zendsearch/library/ZendSearch/Lucene/Index/SegmentWriter/DocumentWriter.php(166): ZendSearch\\Lucene\\Index\\SegmentWriter\\AbstractSegmentWriter->addStoredFields(Array)
#2 /var/www/html/vendor/handcraftedinthealps/zendsearch/library/ZendSearch/Lucene/Index/Writer.php(231): ZendSearch\\Lucene\\Index\\SegmentWriter\\DocumentWriter->addDocument(Object(ZendSearch\\Lucene\\Document))
#3 /var/www/html/vendor/handcraftedinthealps/zendsearch/library/ZendSearch/Lucene/Index.php(1132): ZendSearch\\Lucene\\Index\\Writer->addDocument(Object(ZendSearch\\Lucene\\Document))
#4 /var/www/html/vendor/massive/search-bundle/Search/Adapter/ZendLuceneAdapter.php(172): ZendSearch\\Lucene\\Index->addDocument(Object(ZendSearch\\Lucene\\Document))
#5 /var/www/html/vendor/massive/search-bundle/Search/SearchManager.php(178): Massive\\Bundle\\SearchBundle\\Search\\Adapter\\ZendLuceneAdapter->index(Object(Sulu\\Bundle\\SearchBundle\\Search\\Document), \'massive_article...\')
#6 /var/www/html/vendor/sulu/content-bundle/Content/Application/ContentIndexer/ContentIndexer.php(60): Massive\\Bundle\\SearchBundle\\Search\\SearchManager->index(Object(Namespace\\Bundle\\ArticleBundle\\Entity\\ArticleDimensionContent))
#7 /var/www/html/vendor/sulu/content-bundle/Content/Application/ContentIndexer/ContentIndexer.php(49): Sulu\\Bundle\\ContentBundle\\Content\\Application\\ContentIndexer\\ContentIndexer->indexDimensionContent(Object(Namespace\\Bundle\\ArticleBundle\\Entity\\ArticleDimensionContent))
#8 /var/www/html/bundles/sulu-article-bundle/Controller/ArticleController.php(248): Sulu\\Bundle\\ContentBundle\\Content\\Application\\ContentIndexer\\ContentIndexer->index(Object(Namespace\\Bundle\\ArticleBundle\\Entity\\Article), Array)
#9 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(157): Namespace\\Bundle\\ArticleBundle\\Controller\\ArticleController->putAction(Object(Symfony\\Component\\HttpFoundation\\Request), 1)
#10 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(79): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 1)
#11 /var/www/html/vendor/symfony/http-kernel/Kernel.php(195): Symfony\\Component\\HttpKernel\\HttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)
#12 /var/www/html/public/index.php(66): Symfony\\Component\\HttpKernel\\Kernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))
#13 {main}

Example

Here is our template example:

<?xml version="1.0" ?>
<template xmlns="http://schemas.sulu.io/template/template"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/template-1.0.xsd">

    <key>default</key>

    <view>articles/default</view>
    <controller>Sulu\Bundle\WebsiteBundle\Controller\DefaultController::indexAction</controller>
    <cacheLifetime>604800</cacheLifetime>

    <meta>
        <title lang="en">Article</title>
        <title lang="de">Artikel</title>
    </meta>

    <properties>
        <property name="title" type="text_line" mandatory="true">
            <meta>
                <title lang="en">Title</title>
                <title lang="de">Titel</title>
            </meta>

            <params>
                <param name="headline" value="true"/>
            </params>

            <tag name="sulu.rlp.part"/>
            <tag name="sulu.search.field" role="title"/>
        </property>

        <property name="url" type="route">
            <meta>
                <title lang="en">Resourcelocator</title>
                <title lang="de">Adresse</title>
            </meta>

            <tag name="sulu.rlp"/>
            <tag name="sulu.search.field" role="url"/>
        </property>

        <property name="teaser_text" type="text_area">
            <meta>
                <title lang="en">Teaser Text</title>
                <title lang="de">Teaser Test</title>
            </meta>

            <tag name="sulu.search.field" role="description"/>
        </property>

        <property name="teaser_image" type="single_media_selection">
            <meta>
                <title lang="en">Teaser Image</title>
                <title lang="de">Teaser Bild</title>
            </meta>

            <tag name="sulu.search.field" role="image"/>
        </property>
    </properties>
</template>
@alexander-schranz alexander-schranz added the Bug Error or unexpected behavior of already existing functionality label Feb 5, 2021
@Jupi007
Copy link

Jupi007 commented Mar 13, 2023

I am experiencing the exact same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Error or unexpected behavior of already existing functionality
Projects
None yet
Development

No branches or pull requests

3 participants