10up / ElasticPress

A fast and flexible search and query engine for WordPress.
https://elasticpress.io
GNU General Public License v2.0
1.24k stars 312 forks source link

QUESTION: Cannot search through all sites of multisite setup #2598

Closed moritzlang closed 2 years ago

moritzlang commented 2 years ago

Hi,

I am trying to search through all sites of my multisite setup, but as soon as I turn on "sites" => "all" no results are returned.

The query:

$posts = get_posts(array(
    "ep_integrate" => true,
    "sites" => "all",
    "s" => "foo",
    "posts_per_page" => -1,
  ));

Response from the debug bar:

{
    "error": {
        "root_cause": [
            {
                "type": "index_not_found_exception",
                "reason": "no such index [REDACTED-post-global]",
                "resource.type": "index_or_alias",
                "resource.id": "REDACTED-post-global",
                "index_uuid": "_na_",
                "index": "REDACTED-post-global"
            }
        ],
        "type": "index_not_found_exception",
        "reason": "no such index [REDACTED-post-global]",
        "resource.type": "index_or_alias",
        "resource.id": "REDACTED-post-global",
        "index_uuid": "_na_",
        "index": "REDACTED-post-global"
    },
    "status": 404
}

I already tried to run wp elasticpress recreate-network-alias, but this did not help.

oscarssanchez commented 2 years ago

Hi @moritzlang

What's the output from wp elasticpress recreate-network-alias ?

Based on what you shared, it seems the global alias was not created. If it says Done. after the recreate command, can you check all of the indices with get-indexes and see if you have that index-post-global index ?

moritzlang commented 2 years ago

@oscarssanchez

wp elasticpress recreate-network-alias returns "Success: Done", but when I check with get-indexes no global index was created.

Environment information

Site Health Info: ### wp-core ### version: 5.8.1 site_language: de_AT user_language: en_US timezone: +00:00 permalink: /%postname%/ https_status: false multisite: true user_registration: false blog_public: 1 default_comment_status: open environment_type: production user_count: 84 site_count: 17 network_count: 1 dotorg_communication: true ### wp-active-theme ### name: Theme (theme/resources) version: 9.0.10 author: Roots author_website: https://roots.io/ parent_theme: none theme_features: core-block-patterns, widgets-block-editor, soil-clean-up, soil-jquery-cdn, soil-nav-walker, soil-nice-search, soil-relative-urls, title-tag, menus, post-thumbnails, html5, customize-selective-refresh-widgets, editor-style, widgets theme_path: /Users/mla/Documents/projects/REDACTED/public/app/themes/theme/resources ### wp-mu-plugins (1) ### WP Migrate DB Pro Compatibility: version: 1.2, author: Delicious Brains ### wp-plugins-active (16) ### Advanced Custom Fields: Extended PRO: version: 0.8.8.3, author: ACF Extended (latest version: 0.8.8.6) Advanced Custom Fields: Multisite Select: version: 1.0.0, author: James H-Hall Advanced Custom Fields PRO: version: 5.9.6, author: Elliot Condon (latest version: 5.11.3) Classic Editor: version: 1.6.2, author: WordPress Contributors ElasticPress: version: 3.6.6, author: 10up PublishPress Capabilities: version: 2.2, author: PublishPress (latest version: 2.3) PublishPress Permissions: version: 3.5.7, author: PublishPress (latest version: 3.6.5) Required taxonomies: version: 1.1.7, author: VegaCorp Smash Balloon Instagram Feed: version: 2.9.3.1, author: Smash Balloon (latest version: 2.9.7) WP Migrate DB Pro: version: 2.2.0, author: Delicious Brains (latest version: 2.2.1) WP Migrate DB Pro CLI: version: 1.6.0, author: Delicious Brains WP Migrate DB Pro Media Files: version: 2.1.0, author: Delicious Brains WP Migrate DB Pro Multisite Tools: version: 1.4.0, author: Delicious Brains (latest version: 1.4.1) WP Migrate DB Pro Theme & Plugin Files: version: 1.2.0, author: Delicious Brains Yoast Duplicate Post: version: 4.1.2, author: Enrico Battocchi & Team Yoast (latest version: 4.2) Yoast SEO: version: 17.1, author: Team Yoast (latest version: 17.7.1) ### wp-plugins-inactive (10) ### ACF: FocusPoint: version: 1.1.8, author: Oskari Oksanen Add From Server: version: 3.4.5, author: Dion Hulse Advanced Custom Fields: Icon Picker: version: 1.9.0, author: Houke de Kwant Cache Enabler: version: 1.8.4, author: KeyCDN (latest version: 1.8.7) CDN Enabler: version: 2.0.4, author: KeyCDN Multisite Post Duplicator: version: 1.7.6, author: Mario Jaconelli Password Policy Manager: version: 1.1.4, author: miniOrange Sucuri Security - Auditing, Malware Scanner and Hardening: version: 1.8.28, author: Sucuri Inc. (latest version: 1.8.30) User Switching: version: 1.5.7, author: John Blackbourn & contributors (latest version: 1.5.8) WP 2FA - Two-factor authentication for WordPress: version: 1.7.1, author: WP White Security ### wp-media ### image_editor: WP_Image_Editor_GD imagick_module_version: Not available imagemagick_version: Not available imagick_version: Not available file_uploads: File uploads is turned off post_max_size: 512M upload_max_filesize: 512M max_effective_size: 512 MB max_file_uploads: 20 gd_version: 2.3.2 gd_formats: GIF, JPEG, PNG, WebP, BMP, XPM ghostscript_version: not available ### wp-server ### server_architecture: Darwin 20.4.0 x86_64 httpd_software: nginx/1.19.6 php_version: 7.4.20 64bit php_sapi: fpm-fcgi max_input_variables: 1000 time_limit: 30 memory_limit: 512M max_input_time: 60 upload_max_filesize: 512M php_post_max_size: 512M curl_version: 7.78.0 (SecureTransport) OpenSSL/1.1.1k suhosin: false imagick_availability: false pretty_permalinks: true ### wp-database ### extension: mysqli server_version: 5.7.34 client_version: mysqlnd 7.4.20 ### wp-constants ### WP_HOME: http://REDACTED.test WP_SITEURL: http://REDACTED.test WP_CONTENT_DIR: /Users/mla/Documents/projects/REDACTED/public/app WP_PLUGIN_DIR: /Users/mla/Documents/projects/REDACTED/public/app/plugins WP_MEMORY_LIMIT: 64M WP_MAX_MEMORY_LIMIT: 512M WP_DEBUG: true WP_DEBUG_DISPLAY: true WP_DEBUG_LOG: true SCRIPT_DEBUG: false WP_CACHE: false CONCATENATE_SCRIPTS: undefined COMPRESS_SCRIPTS: undefined COMPRESS_CSS: undefined WP_LOCAL_DEV: undefined DB_CHARSET: utf8 DB_COLLATE: undefined ### wp-filesystem ### wordpress: writable wp-content: writable uploads: writable plugins: writable themes: writable mu-plugins: writable
felipeelia commented 2 years ago

Hi @moritzlang,

get-indexes won't return aliases, even if they were correctly created. To get a list of aliases you can use wp elasticpress request _cat/aliases. Also, can you also run wp elasticpress get-indexes and then wp elasticpress index --setup --yes --network-wide --show-errors and send us the output? In addition to all that, it would be great if you could install Debug Bar and Debug Bar ElasticPress, run that get_posts() call and send us the query fired and the URL used.

Thanks

github-actions[bot] commented 2 years ago

This issue has been automatically closed because there has been no response to our request for more information. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further. See this blog post on bug reports and the importance of repro steps for more information about the kind of information that may be helpful.

moritzlang commented 2 years ago

Hi @felipeelia,

first wp elasticpress request _cat/aliases did not show any output, but after running:

wp elasticpress index --setup --yes --network-wide --show-errors output:

Success: Mapping sent
Success: Mapping sent
Success: Mapping sent
Success: Mapping sent
Success: Mapping sent
Success: Mapping sent
Success: Mapping sent
Success: Mapping sent
Success: Mapping sent
Success: Mapping sent
Indexing objects network-wide...
Indexing posts on site 1...
Processed 328/328. Last Object ID: 2
Number of posts indexed on site 1: 328
Indexing posts on site 2...
Processed 350/328. Last Object ID: 3153
Processed 700/1163. Last Object ID: 2385
Processed 1050/1163. Last Object ID: 1125
Processed 1163/1163. Last Object ID: 385
Number of posts indexed on site 2: 1163
Indexing posts on site 5...
Processed 308/328. Last Object ID: 30
Number of posts indexed on site 5: 308
Indexing posts on site 9...
Processed 283/328. Last Object ID: 29
Number of posts indexed on site 9: 283
Indexing posts on site 10...
Processed 200/328. Last Object ID: 29
Number of posts indexed on site 10: 200
Indexing posts on site 11...
Processed 350/328. Last Object ID: 2525
Processed 700/759. Last Object ID: 270
Processed 759/759. Last Object ID: 29
Number of posts indexed on site 11: 759
Indexing posts on site 12...
Processed 66/328. Last Object ID: 30
Number of posts indexed on site 12: 66
Indexing posts on site 15...
Processed 159/328. Last Object ID: 6
Number of posts indexed on site 15: 159
Indexing posts on site 17...
Processed 157/328. Last Object ID: 341
Number of posts indexed on site 17: 157
Indexing posts on site 20...
Processed 127/328. Last Object ID: 2
Number of posts indexed on site 20: 127
Recreating post network alias...
Total time elapsed: 104,792
Success: Done!
Adding post mapping for site 1...
Adding post mapping for site 2...
Adding post mapping for site 5...
Adding post mapping for site 9...
Adding post mapping for site 10...
Adding post mapping for site 11...
Adding post mapping for site 12...
Adding post mapping for site 15...
Adding post mapping for site 17...
Adding post mapping for site 20...

The output showed all global indexes and the query works now as it should

wp elasticpress request _cat/aliases output:

REDACTED-post-global REDACTED-post-10       - - - -
REDACTED-post-global REDACTED-post-2        - - - -
REDACTED-post-global REDACTED-post-15 - - - -
REDACTED-post-global REDACTED-post-5           - - - -
REDACTED-post-global REDACTED-post-20           - - - -
REDACTED-post-global REDACTED-post-12     - - - -
REDACTED-post-global REDACTED-post-17      - - - -
REDACTED-post-global REDACTED-post-11     - - - -
REDACTED-post-global REDACTED-post-1                - - - -
REDACTED-post-global REDACTED-post-9            - - - -

Any idea why this happened?

Thanks for your help on this!

felipeelia commented 2 years ago

Good to see things worked @moritzlang! As far as why it happened, probably you had a problem sending the mapping before but I can't be 100% sure on that. If you ever see this problem happening again, let us know. Thanks!

moritzlang commented 2 years ago

Hi @felipeelia,

I noticed that after clicking the sync button in the Wordpress Admin the aliases are gone again. When executing wp elasticpress index --setup --yes --network-wide --show-errors the aliases are there again. I didn't dig deeper into the issue, just wanted to let you know this.

Is there any issue on the performance/quality of the results when setting the IDs of all indexable sites like this 'sites' => [1, 2, 5, 6, 19, 22] vs using 'sites' => 'all'?