Skip to content

Conversation

@Fran-A-Dev
Copy link
Contributor

Changes
smart-search-plugin.mjs

  • Refactored to ensure consistent ID generation for MDX documents using cleaned paths, preventing duplicates in the search index.

  • Updated deleteExistingDocs to use the deleteMany mutation, targeting content_type: 'mdx_doc' and removing any residual documents.

  • Added detailed logging during indexing to aid in debugging and ensure proper paths and IDs for indexed documents.

pages/api/search.js
Modified the search API handler to:

  • Handle both content_type and post_type fields to ensure compatibility with existing WordPress and MDX content in the search index.

  • Remove duplicates from search results using a unique filter based on document IDs.

  • Clean up paths for MDX content by stripping unnecessary prefixes like src/pages and pages/ and trimming .mdx extensions.

Properly map and format results for:

MDX documents (content_type: 'mdx_doc')
WordPress posts (content_type: 'wp_post' or post_type: 'post').

Bug Fixes

  • Eliminated duplicate entries in the search results.
  • Resolved issues with "Untitled" entries for MDX documents.

Results:

  • Ensuring search results are clean, accurate, and free of duplicates.
  • Properly supporting both MDX and WordPress content types.
  • Maintaining consistency in path formatting and document indexing.

@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-remove-elastic-search-duplicates https://h5…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

Copy link
Member

@moonmeister moonmeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good

@Fran-A-Dev Fran-A-Dev merged commit c7466fb into toolkit Nov 20, 2024
2 of 3 checks passed
@Fran-A-Dev Fran-A-Dev deleted the remove-elastic-search-duplicates branch November 20, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants