Collective.elasticsearch ES 8 support, AI and more

Hello everyone,

I started implementing Elasticsearch 8 support for collective.elasticsearch. I called it 6.x branch. :slight_smile: Currently, it still supports Plone 5.2 and Plone 6 and Elasticsearch 7/8. I also merged some older bug fixes and features into this branch.

It’s the backbone for all search/list/query-related requests in our Plone-based ecosystem.
So I do have a genuine interest in this package, and I’m happy to maintain it. Thanks @ericof and others for putting in the effort so far :flexed_biceps:

Would it be possible to get maintainer access on pypi for the package? My pypi username is “maethu“.
I would like to get some releases out there! You can ping me if there is an open issue or PR you would like to see resolved or merged.

To the AI part:
I have a POC of a RAG Q&A, basically using the current architecture and hooking up an external/local embedding model and an LLM (using openai lib).

If you run collective.elasticsearch with Redis, the indexing is handled by a worker and does not bother your Plone instance much anymore. The same happens with the embeddings.

+------------------+     +------------------+     +------------------+
|   Plone CMS      |     |   Redis/RQ       |     |  Elasticsearch   |
|                  |     |   Worker         |     |                  |
|  - REST API      |---->|  - Embedding     |---->|  - Chunks Index  |
|  - Subscribers   |     |    Generation    |     |  - kNN + BM25    |
+------------------+     +------------------+     +------------------+
                                  |
                                  v
                         +------------------+
                         |  Ollama/Mistral  |
                         |  - Embeddings    |
                         |  - LLM Chat      |
                         +------------------+

With ES 8, you can store and query vectors, which makes it possible to use it as a store for all vectorized data. The SearchableText is already a plain-text version of whatever needs to be indexed, and it is already in a good format for the embedding service. ES 8 can extract text from nearly everything.

Example request:

curl --location 'http://localhost:8080/Plone/@rag-ask' 
--header 'Accept: application/json' 
--header 'Content-Type: application/json' 
--data '    {
"question": "What is the address of the tax administration?",
"top_k": 5
}'  

Response:


{
    "@id": "http://localhost:8080/Plone/@rag-ask",
    "answer": "The address of the tax office is: \n\Somestreet 100\n12345 City\n+00 00 00 00 00",
    "question": "What is the address of the tax administration?",
    "sources": [
        {
            "chunk_index": 0,
            "path": "/Plone/to/a/contact/in/plone",
            "score": 32.188305,
            "title": "Address of tax administration building"
        },
        {
            "chunk_index": 3,
            "path": "/Plone/path/to/news",
            "score": 20.34761,
            "title": "New tax administration building address"
        },
        ....
    ]
}


At the last Plone conference, there was a lot of discussion about Plone being late to the game. Maybe this is a step forward toward having a “plugin” that provides at least an entry point, without an external vector DB.

I’m wondering if there are others out there who would be interested in pursuing this potential approach to AI integration in Plone.

Cheers,
Mathias

2 Likes

A bit off-topic or not: although Elasticsearch is great tool, I would recommend to use Typesense since since it provides:

  • almost the same functionality
  • has AI/RAG support
  • can be clustered
  • a single binary (compared to Java as runtime requirement for ES)
  • declarative search UIs for facted search

We integrated Typesense in two projects with very good success. However without deep integration (we export Plone data as JSON and import it regularly into Typesense since our usecases allow it). @MrTango has been working on a deeper integration with Plone.

2 Likes

I like the single binary approach, and the fact it does not need 20GB RAM seems kind of teasing.

But I’m not sure how easily I can switch :frowning: Like I said, it’s the backbone of all of our installations regarding search/query/ai stuff. I also use a good amount of features from ES that, at least as far as I can see (or the AI can see), are not directly available in Typesense. Like processing pipelines, tons of aggregations (also nested aggs), nested queries, hybrid search (vector and regular)… probably more.

I assume it’s this GitHub - plone/plone.typesense: Typesense integration for Plone WIP package? Thanks for pointing that out. I’ll have a look and report back if I go down this road.

I am aware that it is not easy right away from ES to Typesense.
We went for a lose integration (we don't want to replace the portal_catalog and we don't need to integrate with ZODB transactions for sites with a low amount of changes). Writing an exporter from Plone and an import for Typesense is more or less a no-brainer. Setting up a UI with facted search takes a bit of time but works perfectly. See here for a faceted search across medical guidelines:

Hello Mathias,

I can make a release as soon as you need one.

Also, I'm willing to start a >= Plone 6.1 branch of the package following all the new code standards we've been using in cookieplone.

Best,
ea