Anyone use the page from API Platform Elastic Search Integration – seems out of date?

I’m trying to follow this page:
https://api-platform.com/docs/v3.0/core/elasticsearch/

I’m storing data in elastic search without also storing it in my database. I understand that the API-Platform has read capability for elastic search, but I had to do a lot of tweaks from what was published in order to get anything to work from elastic search.

Has anyone ran into this?

Here’s my versions from composer.json


"require": {
    "php": ">=8.2",
    "api-platform/core": "^3.2",
    "doctrine/dbal": "^3",
    "doctrine/doctrine-bundle": "^2.12",
    "doctrine/doctrine-fixtures-bundle": "^3.5",
    "doctrine/doctrine-migrations-bundle": "^3.3",
    "doctrine/orm": "^2.5",
    "elasticsearch/elasticsearch": "^7.11"
  },

My elastic search running locally:


    "name": "****************",
    "cluster_name": "elasticsearch",
    "cluster_uuid": "k8_akPPcRmSFZAGmm5IA_g",
    "version": {
        "number": "8.13.3",
        "build_flavor": "default",
        "build_type": "deb",
        "build_hash": "617f7b76c4ebcb5a7f1e70d409a99c437c896aea",
        "build_date": "2024-04-29T22:05:16.051731935Z",
        "build_snapshot": false,
        "lucene_version": "9.10.0",
        "minimum_wire_compatibility_version": "7.17.0",
        "minimum_index_compatibility_version": "7.0.0"
    },
        "tagline": "You Know, for Search"
}

Following the page
https://api-platform.com/docs/v3.0/core/elasticsearch/

I get errors when putting the index definitions in for user and tweet.
The _doc is not accepted in elastic search anymore so I had to remove that key from the example.

When I made the models in the model bundle, they appeared in OpenAPI docs for my API but they were full collection and not tied to elastic search?

I’m not sure from the directions how/why they think the OpenAPI code will know those specific entities are in elastic search?

I had to change the APIResource definitions to for user:

use ApiPlatformElasticsearchStateCollectionProvider;
use ApiPlatformElasticsearchStateItemProvider;
use ApiPlatformElasticsearchStateOptions;

#[ApiResource(
    operations: [
        new GetCollection(provider: CollectionProvider::class, stateOptions: new Options(index: 'user')),
        new Get(provider: ItemProvider::class, stateOptions: new Options(index: 'user')),
    ],
)]

The page states:

API Platform will automatically disable write operations and snake case document fields will automatically be converted to camel case object properties during serialization.

This did not work for me, I had to change the model definition for user to exactly match the naming convention used when creating my schema in elastic search. This meant renaming the $firstName to $first_name and $lastName to $last_name in the model for user.

I guess my questions are:

  • has anyone followed the directions on that page and got it to work without all these tweaks?
  • am I missing something or just elasticsearch and the elasticsearch library just made changes and the documentation hasn’t kept up?
  • Anyone have any direction before I start using this with my own project entities/indexes that the page is omitting?

New contributor

Jim Glenn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật