Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce IndexNotFoundException (BC Break) #470

Conversation

alexander-schranz
Copy link
Member

@alexander-schranz alexander-schranz commented Dec 27, 2024

This PR should let us check if all search engines throw a not found exception which we may can catch and rethrow our own exception to maybe build up a auto setup in future (see #463).

BC Breaks

New recommended way to setup Elasticsearch and Opensearch is to disable auto create of indexes, this avoids that a false Schema of your index is created in any case:

services:
  elasticsearch:
    image: # ...
    environment:
      # ...
+     action.auto_create_index: 'false'
    # ...

Existing clusters can be updated with:

curl -X PUT "http://localhost:9200/_cluster/settings" \
-H "Content-Type: application/json" \
-d '{
  "persistent": {
    "action.auto_create_index": "false"
  }
}'

Todo

  • ⚪ Memory (custom handeled)
  • ⚪ Loupe (custom handeled / by default autocreated with custom settings)
  • ⚠️ Elasticsearch (only with custom setting we get error or 404 else autocreated with basic engine specific settings)
  • ⚠️ Opensearch (not tested but think same as Elasticsearch)
  • ❌ Algolia (no error thrown - autocreated with basic engine specific settings)
  • ❌ Meilisearch (no error thrown - autocreated with basic engine specific settings)
  • ❌ Redisearch (no error thrown - document created but Index not as 2 JSON.SET and FT are two different modules)
  • ⚪ Solr (throws 404)
  • ⚪ Typesense (throws a NotFoundObject exception)

@alexander-schranz alexander-schranz added features New feature or request Adapter: Elasticsearch Elasticsearch Adapter releated issue Adapter: Opensearch Opensearch Adapter related issue Adapter: Memory Memory Adapter related issue Adapter: ReadWrite ReadWrite Adapter related issue Adapter: Multi Multi Adapter related issue Adapter: Meilisearch Meilisearch Adapter related issue Adapter: Algolia Algolia Adapter related issue Adapter: Solr Solr Adapter related issue Adapter: Typesense Typesense Adapter related issue Adapter: RediSearch RediSearch Adapter related issue Adapter: Loupe Loupe Adapter related issue labels Dec 27, 2024
@alexander-schranz alexander-schranz changed the title Introduce IndexNotFoundException Introduce IndexNotFoundException (BC Break) Dec 27, 2024
@alexander-schranz
Copy link
Member Author

It seems like we are not possbile to standardize this as a lot of Search Engines do not fail when try to add documents to a none existing Index. While for example Elasticsearch and Opensearch have some settings to force error on none created Indexes. Search engines like Algolia and Meilisearch do not have this options. Same for Redisearch which even allow to add Documents but as no Index is created search will still fail.

Sadly this also means we can not force that a Index is created with the correct settings and so can fail if something isn't correct. As we are not able to standardize a index not found exception we are also not able to implement auto create for all engines correctly. So the search engines will behave differently if you try to add a document to none existing Engine.

As request by @Toflar we will support Autocreate for Indexes of Loupe in #471.

alexander-schranz added a commit that referenced this pull request Jan 2, 2025
…471)

Sadly it seems like we are not able to standardize
IndexNotFoundException (#470)
for save, delete, bulk or search actions.

We will still support in Loupe Autocreate of the Index if it does not
yet exists.

While Indexes are in some cases autocreated we recommend to create
Indexes via the frameworks CLI commands / scripts. Else Search Engine
will create there own setting for the indexes and things like
searchable, filterable, sortable, does may not work like expected. Why
this is not the case for Loupe it is case for other Engine which also
support auto create:

 - Elasticsearch
 - Opensearch
 - Algolia
 - Meilisearch
 
They all create indexes with some kind of default settings not the
defined mapping of yours.

The following search engines will just fail if you try to save, delete,
... a document from it:

 - Solr
 - Typesense
 
The following search engines will not fail when adding, deleting a
document but still no Index exist so nothing is searchable.

 - Redisearch

So fixes only parts of #463.

---

TLDR; Only adapters which auto create indexes with correct configuration
are with this PR:

 - Loupe
 - Memory
 
All others are not created with the correct settings and createIndex
should definitely still be called for them to update the settings of the
specific engines correctly.
alexander-schranz added a commit to PHP-CMSIG/seal-loupe-adapter that referenced this pull request Jan 2, 2025
…#471)

Sadly it seems like we are not able to standardize
IndexNotFoundException (PHP-CMSIG/search#470)
for save, delete, bulk or search actions.

We will still support in Loupe Autocreate of the Index if it does not
yet exists.

While Indexes are in some cases autocreated we recommend to create
Indexes via the frameworks CLI commands / scripts. Else Search Engine
will create there own setting for the indexes and things like
searchable, filterable, sortable, does may not work like expected. Why
this is not the case for Loupe it is case for other Engine which also
support auto create:

 - Elasticsearch
 - Opensearch
 - Algolia
 - Meilisearch
 
They all create indexes with some kind of default settings not the
defined mapping of yours.

The following search engines will just fail if you try to save, delete,
... a document from it:

 - Solr
 - Typesense
 
The following search engines will not fail when adding, deleting a
document but still no Index exist so nothing is searchable.

 - Redisearch

So fixes only parts of PHP-CMSIG/search#463.

---

TLDR; Only adapters which auto create indexes with correct configuration
are with this PR:

 - Loupe
 - Memory
 
All others are not created with the correct settings and createIndex
should definitely still be called for them to update the settings of the
specific engines correctly.
alexander-schranz added a commit to PHP-CMSIG/seal-memory-adapter that referenced this pull request Jan 2, 2025
…#471)

Sadly it seems like we are not able to standardize
IndexNotFoundException (PHP-CMSIG/search#470)
for save, delete, bulk or search actions.

We will still support in Loupe Autocreate of the Index if it does not
yet exists.

While Indexes are in some cases autocreated we recommend to create
Indexes via the frameworks CLI commands / scripts. Else Search Engine
will create there own setting for the indexes and things like
searchable, filterable, sortable, does may not work like expected. Why
this is not the case for Loupe it is case for other Engine which also
support auto create:

 - Elasticsearch
 - Opensearch
 - Algolia
 - Meilisearch
 
They all create indexes with some kind of default settings not the
defined mapping of yours.

The following search engines will just fail if you try to save, delete,
... a document from it:

 - Solr
 - Typesense
 
The following search engines will not fail when adding, deleting a
document but still no Index exist so nothing is searchable.

 - Redisearch

So fixes only parts of PHP-CMSIG/search#463.

---

TLDR; Only adapters which auto create indexes with correct configuration
are with this PR:

 - Loupe
 - Memory
 
All others are not created with the correct settings and createIndex
should definitely still be called for them to update the settings of the
specific engines correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Adapter: Algolia Algolia Adapter related issue Adapter: Elasticsearch Elasticsearch Adapter releated issue Adapter: Loupe Loupe Adapter related issue Adapter: Meilisearch Meilisearch Adapter related issue Adapter: Memory Memory Adapter related issue Adapter: Multi Multi Adapter related issue Adapter: Opensearch Opensearch Adapter related issue Adapter: ReadWrite ReadWrite Adapter related issue Adapter: RediSearch RediSearch Adapter related issue Adapter: Solr Solr Adapter related issue Adapter: Typesense Typesense Adapter related issue features New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant