Elasticpress: No results in WooCommerce admin order search

Created on 20 Mar 2017  路  39Comments  路  Source: 10up/ElasticPress

With ElasticPress enabled, the order search in WooCommerce admin returns nothing for name, email, possibly other fields. Order number is found correctly. Disabling ElasticPress returns the correct/expected order search results.

I noticed in the 2.2 changelog it mentions 'WooCommerce order search broken' - can you elaborate. I assume it means you had issues, that were resolved in 2.2!

question

All 39 comments

Hi @chercka,
Did you run a sync after activating?

Which version of Elasticsearch, WooCommerce, and WordPress are you running?

Hi @allan23,
Yes we've synced several times since activation.
We are running latest versions of everything.

WooCommerce 2.6.14
ElasticPress 2.2
WordPress 4.7.3

@chercka please email me at taylor.[email protected]

@chercka there is a possibility that the indexing has failed to index all the orders. maybe related to #722
if you can get me the debug.log / error_log file that would be good to start with.

Hi @ivankristianto attached is the error log - thanks!

error_log.zip

@chercka we need to figure out two things:
1) Was there an error in putting the mapping? You'll need to manually do a put mapping and debug output to check this. CLI let's you easily do a put mapping.
2) You will need to install the ElasticPress Debug Bar and send us the formatted request/response for order search

@chercka I cannot replicate the issue you are having.
But for the information, in Admin Order search elasticpress will search into these fields:

"fields": [
                                    "post_title",
                                    "post_content",
                                    "post_excerpt",
                                    "meta._order_key.value",
                                    "meta._billing_company.value",
                                    "meta._billing_address_1.value",
                                    "meta._billing_address_2.value",
                                    "meta._billing_city.value",
                                    "meta._billing_postcode.value",
                                    "meta._billing_country.value",
                                    "meta._billing_state.value",
                                    "meta._billing_email.value",
                                    "meta._billing_phone.value",
                                    "meta._shipping_address_1.value",
                                    "meta._shipping_address_2.value",
                                    "meta._shipping_city.value",
                                    "meta._shipping_postcode.value",
                                    "meta._shipping_country.value",
                                    "meta._shipping_state.value",
                                    "meta._billing_last_name.value",
                                    "meta._billing_first_name.value",
                                    "meta._shipping_first_name.value",
                                    "meta._shipping_last_name.value"
                                ]

I tried to search using order id, customer name, customer email, and shipping name, it is working as expected.

Can you try to sync using wp-cli?

And you give us the
WP, EP, WC and ES version you are running?

Hey guys,

I'm working on the cli commands you've suggested. (I'm only able to debug on our staging server, so I don't have total freedom).

Attached is the debug bar output when I perform a search for an order in woocommerce admin by email (which I know exists).
debug-bar-output.txt

@ivankristianto the versions are listed above in the thread. Everything is up to date.

@tlovett1, going to pursue that manual put-mapping next. How do we debug the output from it?

Manual sync did not resolve the issue. Waiting on feedback for how to do the put-mapping and debug the output.

@chercka how is your setup?
are you using WP multisite? And do you have multiple webserver setup?

@ivankristianto we are not running multisite. The site has a dedicated elasticpress.
Can you please provide steps on performing the action @tlovett1 suggested: "You'll need to manually do a put mapping and debug output to check this."

@chercka
what is your ElasticSearch version?

to do manually put mapping you can run this command:
wp elasticpress put-mapping

But to do full re-index ( it will destroy old index, rebuild mapping, and reindex all content ), you can run this command:
wp elasticpress index --setup

We are running ElasticPress 2.2.1. Is there a separate ElasticSearch version number you are looking for?

We will try the full re-index.

Here are the results of the full re-index. Something going on during index, but it returns that all 149 posts have been indexed? How else to troubleshoot this?

wp elasticpress index --setup
Adding mapping...
Deleting index...
Success: Index deleted
Success: Mapping sent
Indexing posts...

Oops! It looks like you’re not logged in to your account.

Processed 149/149 entries. . .
Number of posts indexed on site 1: 149
Total time elapsed: 9.600
Success: Done!

Frontend searches appear to be working fine.

Hi @chercka,

What other plugins do you have installed?

Also noticing this fatal PHP error in your logs:
Fatal error: Call to undefined function PETA_Two_Shortcodes\\inc\\peta_get_custom_posts() in /var/www/vhosts/peta2.com/httpdocs/releases/20170207204550/wp-content/plugins/peta2-shortcodes/inc/class-shortcodes.php on line 177

@allan23 it's a massive site with over 150.000 registered users, there are all manner of plugins running, a lot of them 100% custom.

More than a solution, I'm looking for strategies on how to troubleshoot this. For example, since the search is returning no results, does that mean indexing has failed? Or does the manual put-mapping confirm that indexing is succesful, and we are looking at an issue further down the line? How do I troubleshoot this?

@chercka, without knowing all the plugins, it may be difficult to troubleshoot. I would recommend deactivating plugins one by one and performing an index operation to determine if there is an issue with one of them.

You mentioned previously that only 149 posts were indexed. Of these 149 that were indexed, what post type were they? Are there missing post types that should have been indexed?

@allan23

  1. I can run through the plugins and test indexing - how do I know if the indexing is succesful? Is there a way to do this through the admin interface? I don't personally have WP-CLI access and have to go through someone else for this.
  1. 149 posts were indexed on the staging server, correct. How can I see which posts they are?

Any input on how to troubleshoot in response to my 2 questions above?

Hi @chercka,
I have been thinking about ways to help you with your issue, so I have developed a plugin that will generate some debugging information that you can share with us. Can you please install the EP Troubleshooting plugin on your staging site and send us the JSON file?

https://github.com/allan23/ep-troubleshoot/archive/master.zip

Instructions for this plugin can be found here: https://github.com/allan23/ep-troubleshoot/blob/master/README.md

Thanks.

That's a fantastic idea, thanks @allan23 . Attached is the json result.

ep-troubleshoot.json.zip

Thanks for the quick response @chercka. At a glance, it appears that the shop_order post type is not being indexed. This is likely due to the Protected Content feature not being enabled and the order search being conducted through WordPress and not ElasticPress.

On my local setup, I have a few test orders from a customer from Testerville. With Protected Content turned off and performing a search for "Testerville", I get no results. However, when I activate Protected Content, I get results from the search.

We recommend only turning on the Protected Content feature if your Elasticsearch instance is secured. If it is not, we highly recommend checking out https://elasticpress.io/ as a secured Elasticsearch offering that is backed by our support team to help you out if you ever have issues with the instance.

I hope this helps.

Yep, that's definitely the problem.

That's awesome guys, thanks. I'm currently unable to re-index via the WP interface so I'm getting our WP-CLI access guy to do it and will report back. Thanks!

I've enabled Protected Content but am now unable to index. In WP-CLI it goes like this:

wp elasticpress index --setup
Adding mapping...
Deleting index...
Success: Index deleted
Success: Mapping sent
Indexing posts...
Segmentation fault

we had the same issue with the current version of Elasticpress. Using "Protected Content" and standard search for post ID (order ID) - very important, otherwise other searches will break, let's us additionally search fast now for:

  • order ID
  • bill number
  • customer number
  • email
  • name

@fraunholz so you are saying this is working now? Search and Protected Content are required for searching WC orders.

@chercka we'll need to see the error message/stack tract in the logs.

@tlovett1 since it's run through WP-CLI it is not getting logged in the server log. Is there an elasticpress log watching somewhere?

Segmentation Fault is what is output in WP-CLI.

Nope, there is not. You'll need to trace down where that error is coming from. Perhaps, you are running out of memory.

adding post_id to $search_fields allows to search for the order number but breaks for some reasons the search for other name and email. So for searching the order number elasticsearch was skipped, the performance is acceptable since it's using an index for post_id.
Still there are issues when searching with special characters, e.g. '-' or '@' in emails:
max.[email protected] returns all clients with gmail.com addresses.

@fraunholz I made a PR for this #803
can you please check?

I integrated this commit.
The search by email finds wrong orders (see screenshot).
bildschirmfoto 2017-04-18 um 12 00 23

@fraunholz let's continue this in issue #802 to keep this thread relevant.

Server error log when attempting to index 984 items on staging, including protected content:

[Tue Apr 18 11:44:07.191987 2017] [access_compat:error] [pid 47837:tid 140310080325376] [client 173.252.98.86:43055] AH01797: client denied by server configuration: /var/www/vhosts/sitename.com/httpdocs/current/category

[Tue Apr 18 11:44:07.192307 2017] [access_compat:error] [pid 47837:tid 140310080325376] [client 173.252.98.86:43055] AH01797: client denied by server configuration: /var/www/vhosts/sitename.com/httpdocs/current/index.php

[Tue Apr 18 11:44:59.558334 2017] [proxy_fcgi:error] [pid 47837:tid 140310122288896] (70007)The timeout specified has expired: [client 216.27.93.193:42900] AH01075: Error dispatching request to :, referer: http://stage.sitename.com/wp-admin/admin.php?page=elasticpress

The Elasticsearch host is set to http://127.0.0.1:9200. Does this need to configured for https??

As a sidenote perhaps, Disabling protected content and hitting sync seems to run ok for 158 items on staging. Produces this error in the server log though. Maybe nothing.
[Tue Apr 18 11:43:21.048336 2017] [proxy_fcgi:error] [pid 47731:tid 140310105503488] [client 216.27.93.193:42319] AH01071: Got error 'PHP message: PHP Warning: Invalid argument supplied for foreach() in /var/www/vhosts/sitename.com/httpdocs/releases/20170418145306/wp-content/plugins/woocommerce/includes/wc-template-functions.php on line 2222\n', referer: http://stage.sitename.com/wp-admin/admin.php?page=elasticpress

We got admin search to return results once again by removing the filter 'ep_wc_shop_order_search_fields' on init:

add_action( 'init', 'remove_ep_wc_shop_order_search_fields_filter' ); function remove_ep_wc_shop_order_search_fields_filter() { remove_filter( 'woocommerce_shop_order_search_fields', 'ep_wc_shop_order_search_fields', 9999 ); }

What is the reason for this being in EP? If it is only for frontend, then it should be in an is_admin() conditional?

Hmmm, I'm testing EP with Protected Content and WooCommerce enabled. I am getting orders in search when I search by orderer name.

The reason for that being in EP is to prevent an unnecessary meta query from firing.

how to disable the fuzziness? I tried several ways but it keeps showing zero or similar results.
That's ok for names but for customer numbers and order numbers we want only direct hits.

Was this page helpful?
0 / 5 - 0 ratings