1

i'm trying to work with sulu and index content i create from the admin. i create a content, i fill the article field and i publish, but in the index, the "body" of the article is not indexed.

Afaik there is the ObjectToDocumentConverter which converts my object in a document like

AppBundle\Search\Document Object
(
    [contentFields:AppBundle\Search\Document:private] => Array
        (
        )

    [created:protected] => 
    [creatorName:protected] => 
    [creatorId:protected] => 
    [changed:protected] => 
    [changerName:protected] => 
    [changerId:protected] => 
    [properties:protected] => 
    [fields:protected] => Array
        (
            [excerptTitle] => Massive\Bundle\SearchBundle\Search\Field Object
                (
                    [name:protected] => excerptTitle
                    [type:protected] => string
                    [value:protected] => 
                    [stored:protected] => 1
                    [indexed:protected] => 1
                    [aggregate:protected] => 
                )

            [excerptMore] => Massive\Bundle\SearchBundle\Search\Field Object
                (
                    [name:protected] => excerptMore
                    [type:protected] => string
                    [value:protected] => 
                    [stored:protected] => 1
                    [indexed:protected] => 1
                    [aggregate:protected] => 
                )

            [excerptDescription] => Massive\Bundle\SearchBundle\Search\Field Object
                (
                    [name:protected] => excerptDescription
                    [type:protected] => string
                    [value:protected] => 
                    [stored:protected] => 1
                    [indexed:protected] => 1
                    [aggregate:protected] => 
                )

            [excerptCategories] => Massive\Bundle\SearchBundle\Search\Field Object
                (
                    [name:protected] => excerptCategories
                    [type:protected] => array
                    [value:protected] => Array
                        (
                        )

                    [stored:protected] => 1
                    [indexed:protected] => 1
                    [aggregate:protected] => 
                )

            [excerptTags] => Massive\Bundle\SearchBundle\Search\Field Object
                (
                    [name:protected] => excerptTags
                    [type:protected] => array
                    [value:protected] => Array
                        (
                        )

                    [stored:protected] => 1
                    [indexed:protected] => 1
                    [aggregate:protected] => 
                )

            [excerptIcon] => Massive\Bundle\SearchBundle\Search\Field Object
                (
                    [name:protected] => excerptIcon
                    [type:protected] => string
                    [value:protected] => []
                    [stored:protected] => 1
                    [indexed:protected] => 1
                    [aggregate:protected] => 
                )

            [excerptImages] => Massive\Bundle\SearchBundle\Search\Field Object
                (
                    [name:protected] => excerptImages
                    [type:protected] => string
                    [value:protected] => []
                    [stored:protected] => 1
                    [indexed:protected] => 1
                    [aggregate:protected] => 
                )

            [title] => Massive\Bundle\SearchBundle\Search\Field Object
                (
                    [name:protected] => title
                    [type:protected] => string
                    [value:protected] => articulo con todos los campos
                    [stored:protected] => 1
                    [indexed:protected] => 
                    [aggregate:protected] => 1
                )

            [webspace_key] => Massive\Bundle\SearchBundle\Search\Field Object
                (
                    [name:protected] => webspace_key
                    [type:protected] => string
                    [value:protected] => example
                    [stored:protected] => 1
                    [indexed:protected] => 1
                    [aggregate:protected] => 
                )

            [state] => Massive\Bundle\SearchBundle\Search\Field Object
                (
                    [name:protected] => state
                    [type:protected] => string
                    [value:protected] => test
                    [stored:protected] => 1
                    [indexed:protected] => 1
                    [aggregate:protected] => 
                )

            [published] => Massive\Bundle\SearchBundle\Search\Field Object
                (
                    [name:protected] => published
                    [type:protected] => string
                    [value:protected] => 2018-04-04T12:52:27+00:00
                    [stored:protected] => 1
                    [indexed:protected] => 1
                    [aggregate:protected] => 
                )

            [authored] => Massive\Bundle\SearchBundle\Search\Field Object
                (
                    [name:protected] => authored
                    [type:protected] => string
                    [value:protected] => 2018-04-04T12:52:27+00:00
                    [stored:protected] => 1
                    [indexed:protected] => 1
                    [aggregate:protected] => 
                )

            [_structure_type] => Massive\Bundle\SearchBundle\Search\Field Object
                (
                    [name:protected] => _structure_type
                    [type:protected] => string
                    [value:protected] => default
                    [stored:protected] => 1
                    [indexed:protected] => 1
                    [aggregate:protected] => 
                )

        )

    [id:protected] => 9344d287-f400-40cb-85e6-2aeafe1d3ab6
    [class:protected] => Sulu\Bundle\ContentBundle\Document\PageDocument
    [title:protected] => articulo con todos los campos
    [description:protected] => 
    [url:protected] => /articulo
    [imageUrl:protected] => 
    [locale:protected] => en
    [index:protected] => page_example
)

Title, state, and everything you see there is indexed, but which is the best way to index the "body" of that content?

following question will be, is there any way to index everything no matter how your field is called?

Thanks in advance

1 Answers1

2

the only build in way is to add the tag sulu.search.field (see http://docs.sulu.io/en/latest/book/templates.html#search) to each property. but you can simply hook into this process and add a "content" field which concatenate all the properties and index it. see the documentation http://massivesearchbundle.readthedocs.io/en/latest/extending.html#events (massive_search.pre_index).

  • thanks. yes, i realized that after digging a little more in the core. it was easier than i expected. thanks again. – user1643155 Apr 05 '18 at 12:14
  • Also you can reindex existing Pages or Articles with `php bin/websiteconsole massive:search:reindex` after adding this tag – Dr.X May 24 '18 at 13:18