Learn icon indicating copy to clipboard operation
Learn copied to clipboard

Learning Pathway searches broken

Open adamwoodnz opened this issue 1 year ago • 3 comments

Steps to reproduce:

  1. Navigate to a learning pathway, eg. https://learn.wordpress.org/learning-pathway/user/?new-theme=1
  2. Enter a search term matching something you can see in the title or excerpt of the cards displayed, eg. 'friendly' is in the Beginner WordPress User card excerpt
  3. Submit the search, you should land at https://learn.wordpress.org/?s=friendly&wporg_learning_pathway=user

Expected: The search results include the Beginner WordPress User course.

Actual: No results are found.

Before search After search
Image Image

Findings

This works locally. This does not work in prod where we use Jetpack search. I am unsure whether this is the cause. Jetpack search debug:

response_code
200
args
{
  "blog_id": 7,
  "size": 12,
  "from": 0,
  "sort": [
    {
      "_score": {
        "order": "desc"
      }
    }
  ],
  "filter": {
    "and": [
      {
        "terms": {
          "post_type": [
            "post",
            "page",
            "attachment",
            "handbook",
            "course",
            "lesson",
            "lesson-plan",
            "wporg_workshop",
            "glossary"
          ]
        }
      },
      {
        "term": {
          "taxonomy.learning-pathway.slug": "user"
        }
      }
    ]
  },
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "must": [
            {
              "multi_match": {
                "fields": [
                  "title.en^0.1",
                  "content.en^0.1",
                  "excerpt.en^0.1",
                  "tag.name.en^0.1",
                  "category.name.en^0.1",
                  "author_login^0.1",
                  "author^0.1"
                ],
                "query": "friendly",
                "operator": "and"
              }
            }
          ],
          "should": [
            {
              "multi_match": {
                "fields": [
                  "title.en^2.000",
                  "tag.name.en^1.000",
                  "category.name.en^1.000",
                  "author_login^1.000",
                  "author^1.000"
                ],
                "query": "friendly",
                "operator": "and",
                "type": "best_fields"
              }
            },
            {
              "multi_match": {
                "fields": [
                  "title.en^1",
                  "content.en^1",
                  "excerpt.en^1",
                  "tag.name.en^1",
                  "category.name.en^1",
                  "author^1"
                ],
                "query": "friendly",
                "operator": "and",
                "type": "phrase"
              }
            }
          ]
        }
      },
      "functions": [
        {
          "gauss": {
            "date_gmt": {
              "origin": "2024-06-26",
              "scale": "360d",
              "decay": 0.9
            }
          }
        }
      ],
      "max_boost": 2,
      "score_mode": "multiply",
      "boost_mode": "multiply"
    }
  },
  "aggregations": [],
  "fields": [
    "post_id"
  ]
}
Minify
elapsed_time
140.65599441528
es_time
1
url
https://public-api.wordpress.com/rest/v1/sites/47261184/search
response
			{"results":{"total":0,"max_score":null,"hits":[]},"took":1}	

adamwoodnz avatar Jun 26 '24 23:06 adamwoodnz

Presumably when it works locally, it is using wp query, rather than ES to perform the search?

I'd guess that we need to have the new taxonomy in the JP search functionality in order for it to work.

pkevan avatar Jul 02 '24 10:07 pkevan

I'd guess that we need to have the new taxonomy in the JP search functionality in order for it to work.

Data actually looks fine, so it's probably JP query setup that needs tweaking.

pkevan avatar Jul 02 '24 10:07 pkevan

Ah - it's actually a sync specific issue - the list of taxonomies that go into an index is harded coded so they won't ever be present unless the name is changed or the taxonomy gets added to the wp.com specific file.

pkevan avatar Jul 02 '24 14:07 pkevan

Fixed by adding the taxonomy to the JP Search index

adamwoodnz avatar Jul 11 '24 21:07 adamwoodnz