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

Product Custom Field Search Issue #3956

Open asmmcneil opened 1 month ago

asmmcneil commented 1 month ago

Describe your question

We are having an issue with our WP ElasticPress search with expected search results.

If someone searches for two words in one search:

"Word1 Word2" (the product expected is not in the results)

• Search term "Word1" is in the Title of the product • Search term "Word2" is in the same products custom product field

When searched together the product is not in the results; however, if you search for either word by themselves the product is in the search results.

Can you advise what we must do to make the product appear when searching both words?

We use ACF Pro to generate our custom product fields.

Code of Conduct

burhandodhy commented 1 month ago

Hi @asmmcneil,

To diagnose this issue, could you please confirm the following details:

  1. Does the behavior remain the same when you search for "Word1 Word2" or only with the specific terms you are using?
  2. Is the meta field indexed? If not, can you please add the key in ElasticPress -> Search Fields & Weighting.
  3. Can you please share the query body and query result with us? You can learn more about it from here https://www.elasticpress.io/documentation/article/using-the-elasticpress-debugging-add-on-plugin/.

Regards, Burhan

asmmcneil commented 1 month ago

1 .Does the behavior remain the same when you search for "Word1 Word2" or only with the specific terms you are using?

We are seeing this behavior for any search query where one word is in one field and one word is in a different field. If you search "Shipley Failure" on asminternational.org it should include in the search results and does not: https://www.asminternational.org/asm-handbook-volume-11-failure-analysis-and-preventi-1/results/-/journal_content/56/42240310/PUBLICATION/

However if you search "Shipley" or "Failure" by itself you get the product expected.

"Shipley" in a custom product field I have added to the search index.

  1. Yes; it is indexed.
  2. Do you still need this?
asmmcneil commented 1 month ago

debug-bar-elasticpress-report.txt

3 attached I believe

asmmcneil commented 1 month ago

Sorry; just checking in; do you need anything else from me to help figure this out?

github-actions[bot] commented 1 month ago

It has been 3 days since more information was requested from you in this issue and we have not heard back. This issue is now marked as stale and will be closed in 3 days, but if you have more information to add then please comment and the issue will stay open.

felipeelia commented 1 month ago

@asmmcneil you'll have to check where those terms are coming from, and make sure whatever field you are using is indexed and marked as searchable in ElasticPress Field's Dashboard.

For the example you gave, I can see see "Shipley" as an author/Editor, but if you check that same content via WP REST API, you'll see that "Shipley" can't be found: https://www.asminternational.org/wp-json/wp/v2/product/19652

asmmcneil commented 1 month ago

I am confused; if I search "Shipley" the product comes up first position. The field is indexed; it is a custom product field marked as such within ElasticPress. It was not coming up for the search "Shipley" until I had the field indexed.

It seems the URL you provided is the built-in search?

The product in question would be: https://www.asminternational.org/wp-json/wp/v2/product/19657

asmmcneil commented 1 month ago

Both of those books appear in search when you search "Shipley"

https://www.asminternational.org/asm-search/?_search=shipley

But not when you search "Failure Shipley"

asmmcneil commented 4 weeks ago

Just checking in; I have users concerned about search because of this issue.

felipeelia commented 3 weeks ago

@asmmcneil If you go to either https://www.asminternational.org/wp-json/wp/v2/product/19652 or https://www.asminternational.org/wp-json/wp/v2/product/19657 and search for "Shipley" in your browser, you'll see that neither of those two has "Shipley" in its post_content, so it might need to be coming from a meta field. Do you know which field is that? If so, is that field enabled in the Field & Weighting Dashboard?

If you look at the ES queries fired, you'll see that it is only searching for post_title, post_excerpt, post_content, post_author.display_name which could even indicate that although there is a request to ES, your WP site is bypassing ElasticPress completely and still hitting the database for searches. Also, looking at the file you shared, it seems several different requests are being fired to Elasticsearch, you'll have to look into that too.

That said, there is no need to check in. This is an open-source free project that we check regularly, but some replies can take some time. If you have a timeline you need to hit, consider our hourly consulting.

github-actions[bot] commented 3 weeks ago

It has been 3 days since more information was requested from you in this issue and we have not heard back. This issue is now marked as stale and will be closed in 3 days, but if you have more information to add then please comment and the issue will stay open.

asmmcneil commented 3 weeks ago

I do not think you are following the issue; again; by themselves each word render the results expected; however when you combined two words into one search; it is not including results that contain one word in the title and one word in a ACF field like author; which is indexed or else we would not get results.

" Do you know which field is that? If so, is that field enabled in the Field & Weighting Dashboard?" Yes, the author ACF field which is in the weighted section.

felipeelia commented 3 weeks ago

@asmmcneil it is not because a search is returning results that it is using ElasticPress. As I said:

If you look at the ES queries fired, you'll see that it is only searching for post_title, post_excerpt, post_content, post_author.display_name which could even indicate that although there is a request to ES, your WP site is bypassing ElasticPress completely and still hitting the database for searches.

Do you see the same results if you turn EP on and off?

asmmcneil commented 3 weeks ago

That does not answer why the product is in the results when you "shipley"

https://www.asminternational.org/asm-search/?_search=shipley

felipeelia commented 3 weeks ago

@asmmcneil in order to help you, I really need you to answer this question: Do you see the same results if you turn EP on and off?

asmmcneil commented 3 weeks ago

No; different results; the product with the author Shelby does not appear in the search results with EP off.

felipeelia commented 2 weeks ago

Okay, that is a start. Can you please go to https://www.asminternational.org/asm-search/?_search=shipley and share the query body and query result with us (the way @burhandodhy explained?) The previous file you shared was for a search for "Source Sans Pro".

Please note: you should see only ONE query there, if you are seeing multiple, there is something wrong with your code, like running multiple WP_Query's. Also, That contains Elasticsearch's responses, so if you don't see any query result with a hits.total.value greater than 0, your search results are coming from somewhere else.

github-actions[bot] commented 2 weeks ago

It has been 3 days since more information was requested from you in this issue and we have not heard back. This issue is now marked as stale and will be closed in 3 days, but if you have more information to add then please comment and the issue will stay open.

asmmcneil commented 2 weeks ago

debug-bar-elasticpress-report(3).txt

I uploaded this last time as well; let me know if you need anything else.

felipeelia commented 1 week ago

@asmmcneil you have 148 requests being fired there, when you should have only one. That is an underlying issue you'll have to figure out before we can help you. ALL those requests are searches for a totally unrelated term, as you can see by searching for 's' => 'Source Sans Pro', in that log.

There is only ONE request searching for 'shipley'. If you look at the "body" of that query (the query sent to your Elasticsearch server), the fields section contains what is searched:

In the post examples you shared, do you know where in those fields you have the words "Shipley" and "Failure"?

github-actions[bot] commented 1 week ago

It has been 3 days since more information was requested from you in this issue and we have not heard back. This issue is now marked as stale and will be closed in 3 days, but if you have more information to add then please comment and the issue will stay open.

github-actions[bot] commented 6 days ago

This issue has been automatically closed because there has been no response to our request for more information in the past 3 days. With only the information that is currently available, we are unable to take further action on this ticket. Please reach out if you have found or find the answer we need so that we can investigate further. When the information is ready, you can re-open this ticket to share it with us.

asmmcneil commented 6 days ago

Yes; again; it is the title and the author - editor field; Shipley is the author - editor. Failure is coming from the title.

post_title (weigth 90)

author (weigth 12) editor (weigth 14) authors (weigth 17) editors (weigth 18)

felipeelia commented 6 days ago

@asmmcneil, can you please go to that post, open the ElasticPress Debug Bar panel, click on "Reload and retrieve raw ES document", and then after it reloads, share with me the "Query Result" of the "Raw ES document" query?

github-actions[bot] commented 2 days ago

It has been 3 days since more information was requested from you in this issue and we have not heard back. This issue is now marked as stale and will be closed in 3 days, but if you have more information to add then please comment and the issue will stay open.