Errors running 'composer update' with ONGR ES-Bundle

88 Views Asked by At

i'm running the ONGR ElasticSearchBundle in my Symfony Project(prexously i user only the ES-PHP Client). I'll search an existing Index with Company Names and Descriptions, the index Name is companies. It looks this way:

"mappings": {
        "_doc": {
            "properties": {
                "id": {"type": "long"},
                "entityid": {"type": "long"},
                "entityname": {"type": "keyword"},
                "name": {"type": "text"},
                "street": {"type": "text"},
                "city": {"type": "text"},
                "zip": {"type": "long"},
                "ziptext": {"type": "keyword"},
                "regionisocode": {"type": "keyword"},
                "desc": {"type": "text"},
                "branch": {"type": "text"},
                "branchid": {"type": "long"},
                "foundingyear": {"type": "date"}

            }
        }
    }

The Document Class looks this way:

/**
 * Company
 *
 * @ES\Document()
 */
class Company
{
    /**
     * @var string
     *
     * @ES\Property(type="long", options={"index"="not_analyzed"})
     */
    private $id;

    /**
     * @var string
     *
     * @ES\Property(type="long", options={"index"="not_analyzed"})
     */
    private $entityid;

    /**
     * @var string
     *
     * @ES\Property(type="keyword", options={"index"="not_analyzed"})
     */
    private $entityname;
...

When i change the Annotation to:

/**
 * Company
 *
 * @ES\Document(type="_doc")
 */

then The Search is running fine but then i can't execute any composer commands because i get this Error: [RuntimeException]An error occurred when executing the "'cache:clear --no-warmup'" command:[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundExcepton] The service "company_search_service" has a dependency on a non-existent service "es.manager.default.company". I found an Issue in the Bundle on GitHub but it's more than four years a go and its closed.

Without the @ES\Document(type="_doc") Annotation i can't acces the index. Maybe someone has a suggestion? Thank you in advance

I'm using Symfony 2.8 and ONGR/Elastic Bundle 5.2.4

1

There are 1 best solutions below

0
Mantas Marcinkevicius On

I don't know if its still relevant, but the service that is failing is a repository service for your document. It is failing because you are probably requireing it somewhere. The repository service name is made dynamically by appending the manager service name (es.manager.default) with the type name (by default a lowercased document class name, in your case - company), hence - es.manager.default.company. When you add a different type name (_doc in this case) your repository name changes to, I presume, es.manager.default._doc. You could check this and change your service requirements but I would honestly discourage using _doc as type name.