acseo / TypesenseBundle

Typesense PHP integration for your Symfony project
MIT License
59 stars 36 forks source link

Error on document Update #56

Closed Zekemaz closed 1 month ago

Zekemaz commented 2 years ago

Describe the bug

I'm working on a news project on symfony 5.4. In my development environment I use docker but in my prod environment I do not (not my choice) In my development environment everything runs smoothly, I use typesense within a docker container with the image typesense/typesense:0.22.1.

in production environment I'm using acseo/TypesenseBundle^0.6.6 but when I update an article I get the following error : request.CRITICAL: Uncaught PHP Exception Typesense\Exceptions\ObjectNotFound: "Could not find a document with id: 12555" at /httpdocs/vendor/typesense/typesense-php/src/ApiCall.php line 347 {"exception":"[object] (Typesense\\Exceptions\\ObjectNotFound(code: 0): Could not find a document with id: 12555 at /httpdocs/vendor/typesense/typesense-php/src/ApiCall.php:347)"} []

Although when I lauch the following commands, symfony console typesense:create then symfony console typesense:import I get a success message saying [OK] 16024 elements populated in 129.91 seconds, the search engine does not seem to be working.

Expected behavior When I search for an element by title within the search bar I do not get the expected result. I get other articles which have the same keyword present in my query but I don't have the expected article.

For example if I look for an article "The current state of the country" I would expect to get all articles containing those words but especially the one having this exact title. But I only get the articles containing some keywords. I hope I'm making myself clear.

Second Expected behavior When I update an article or any other data used with typesense I would like for it to update by itself and not return a 500 server error saying the document with ID could not be found.

Questions

  1. I don't know what's wrong and I can't figure it out. Has anyone encountered this problem ? I would appreciate any help available. Thank you
  2. Do I need to explicitly tell typesense to update a document ? or does it do it by itself ? I assumed it does it by itself since I have no problem in my development environment

Additional context Here is my typesense configuration

acseo_typesense:
    typesense:
        url: '%env(resolve:TYPESENSE_URL)%'
        key: '%env(resolve:TYPESENSE_KEY)%'
    collections:
        tags:
            entity: 'App\Entity\Tag'
            fields:
                id:
                    name: id
                    type: primary
                sortable_id:
                    entity_attribute: id
                    name: sortable_id
                    type: int32
                name:
                    name: name
                    type: string
                status:
                    name: status
                    type: string
                    facet: true
                createdAt:
                    name: createdAt
                    optional: true
                    type: datetime
            default_sorting_field: sortable_id
        authors:
            entity: 'App\Entity\Author'
            fields:
                id:
                    name: id
                    type: primary
                sortable_id:
                    entity_attribute: id
                    name: sortable_id
                    type: int32
                name:
                    name: name
                    type: string
                description:
                    name: description
                    type: string
            default_sorting_field: sortable_id
        articles:
            entity: 'App\Entity\Article'
            fields:
                id:
                    name: id
                    type: primary
                sortable_id:
                    entity_attribute: id
                    name: sortable_id
                    type: int32
                title:
                    name: title
                    type: string
                slug:
                    name: slug
                    type: string
                content:
                    name: content
                    type: string
                description:
                    name: description
                    type: string
                subCategories:
                    name: subCategories
                    type: collection
                categories:
                    name: categories
                    type: collection
                source.name:
                    entity_attribute: source.name
                    name: source
                    type: string
                tags:
                    name: tags
                    type: collection
                author.name:
                    entity_attribute: author.name
                    facet: true
                    name: author
                    type: string
                publishingDate:
                    name: publishingDate
                    optional: true
                    type: datetime
                status:
                    name: status
                    type: string
                sortable_publishingDate:
                    entity_attribute: publishingDate
                    name: sortable_publishingDate
                    type: datetime
            default_sorting_field: sortable_id
        subscribers:
            entity: 'App\Entity\Subscriber'
            fields:
                id:
                    name: id
                    type: primary
                sortable_id:
                    entity_attribute: id
                    name: sortable_id
                    type: int32
                email:
                    name: email
                    type: string
                firstName:
                    name: firstName
                    type: string
                lastName:
                    name: lastName
                    type: string
                companyName:
                    name: companyName
                    type: string
                job:
                    name: job
                    type: string
                professionalArea:
                    name: professionalArea
                    type: string
            default_sorting_field: sortable_id
EvilSpartans commented 1 year ago

Hi ! Did you find a solution for this ? On my prod env I have same problem and don't understand why

Zekemaz commented 1 year ago

Hey, I am sorry, I will not be able to help you. I quit my job before the problem was solved.

EvilSpartans commented 1 year ago

Hi, I found a solution, I use docker in production too and it work ^^

Zekemaz commented 1 year ago

Would you mind telling me how you fixed the problem?

Thank you