nextcloud / fulltextsearch_elasticsearch

🔍 Use Elasticsearch to index the content of your Nextcloud
GNU Affero General Public License v3.0
81 stars 30 forks source link

Compatibility Issue with Psr\Http\Message\ResponseInterface in Elasticsearch PHP Library - getStatusCode #327

Closed Caney238 closed 10 months ago

Caney238 commented 11 months ago

Description:

I am encountering a fatal PHP error indicating a compatibility issue within the Elasticsearch PHP library when running Full Text Search with Elasticsearch in a Docker container. The error arises when attempting to test the full-text search capabilities.

Error Message:

PHP Fatal error: Declaration of Elastic\Elasticsearch\Response\Elasticsearch::getStatusCode() must be compatible with Psr\Http\Message\ResponseInterface::getStatusCode(): int in /var/www/nextcloud/apps/fulltextsearch_elasticsearch/vendor/elasticsearch/elasticsearch/src/Traits/MessageResponseTrait.php on line 80

Expected Behavior:

The getStatusCode() method should be correctly declared to implement the Psr\Http\Message\ResponseInterface, which expects getStatusCode() to have an int return type.

Current Behavior:

The current declaration of the getStatusCode() method is not compatible with the expected int return type of the ResponseInterface, resulting in a fatal error.

Steps to Reproduce:

Install/configure the Full Text Search app with the Elasticsearch backend in a Docker container. Execute the command to check the full-text search settings. Observe the aforementioned fatal error. Environment:

Nextcloud Version: 27.1.3.2 Full Text Search Elasticsearch App Version: 27.0.4 Elasticsearch Docker Container Version: 8.6.1 (r0wi/elasticsearch-nextcloud-docker) PHP FPM Version: 8.2 Docker-Compose Configuration:

version: '2.2'
services:
  elasticsearch:
    image: r0wi/elasticsearch-nextcloud-docker:${DOCKER_TAG}
    env_file: .env
    container_name: elasticsearch_nc
    restart: always
    environment:
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms2048m -Xmx2048m"
      - discovery.type=single-node
      - xpack.security.enabled=false
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - elasticsearch_data:/usr/share/elasticsearch/data
    ports:
      - 127.0.0.1:9200:9200

volumes:
  elasticsearch_data:

.env

DOCKER_TAG=8.6.1

Additional Context:

The error seems to occur when the Full Text Search app attempts to communicate with the Elasticsearch server within the Docker container.

It is noteworthy to mention that other Nextcloud instances on the same server, which were freshly installed, do not exhibit this issue when interfacing with the same Elasticsearch Docker container. This suggests that the problem may be isolated to the specific Nextcloud instance experiencing the error.

Furthermore, it should be noted that attempts to resolve the issue by uninstalling the Full Text Search app, executing the following SQL commands to clean up the database, and then reinstalling the app, have been unsuccessful. The same error persists post-reinstallation, which further complicates the troubleshooting process.

DROP TABLE IF EXISTS oc_fulltextsearch_index;
DROP TABLE IF EXISTS oc_fulltextsearch_ticks;

DELETE FROM oc_appconfig WHERE appid='fulltextsearch';
DELETE FROM oc_appconfig WHERE appid='fulltextsearch_elasticsearch';
DELETE FROM oc_appconfig WHERE appid='files_fulltextsearch';
DELETE FROM oc_appconfig WHERE appid='files_fulltextsearch_tesseract';
DELETE FROM oc_migrations WHERE app='fulltextsearch';
DELETE FROM oc_preferences WHERE appid='fulltextsearch';

This comprehensive approach was taken in hopes of a clean reset, but the persistent error suggests a deeper underlying issue that is not addressed by these actions.

Moreover, it is important to highlight that the Nextcloud instance encountering this issue has recently undergone a server migration. Post-migration, several Nextcloud OCC commands were executed in an effort to update and re-index Nextcloud. These commands included:

maintenance:repair - This command is used to repair any inconsistencies in the database or filesystem. files:scan --all - This command re-indexes all files. fulltextsearch:index - This command restarts the full-text search indexing process.

Despite these efforts, the issue with the Elasticsearch PHP library persists. The fact that freshly installed Nextcloud instances on the same server, interfacing with the identical Elasticsearch Docker container, are not experiencing this error, reinforces the notion that the issue is specific to this particular instance. Understanding the root cause of this discrepancy, especially in the context of the server migration, is crucial for troubleshooting and resolving the compatibility issue.

Any guidance on additional steps that could be taken to troubleshoot this would be greatly appreciated.

Caney238 commented 11 months ago

The problem that I got would be fixed with this update. Please Update soon. https://github.com/nextcloud/fulltextsearch_elasticsearch/pull/323