Skip to content

Add Search Capability#43

Open
confused-Techie wants to merge 1 commit intomainfrom
search-integration
Open

Add Search Capability#43
confused-Techie wants to merge 1 commit intomainfrom
search-integration

Conversation

@confused-Techie
Copy link
Member

@confused-Techie confused-Techie commented Feb 15, 2026

Still largely a WIP, but this PR adds the ability to search across the docs site.

The general workflow:

  • During build time we generate search-preview.json in the root of the site. This contains a JSON document with a title and summary of each page. The title is easy, but the summary we either need to build from the content, or add it as a required field for each doc page we have.
  1. The user searches in the search box in the top corner of the site
  2. Hitting enter redirects to /search?q=searchTerm
  3. The query is taken by client JS that executes the search against https://search.pulsar-edit.dev (This site needs CORs updates to work in production)
  4. The search is returned by the site, and we then collect the search-preview.json file client side
  5. Display results from the preview according to our returned search on the page.

Items to Complete:

  • Add the docs site into CORs for the search microservice
  • Display skeleton loading items for while the search is executed
  • Display errors or empty results to the user within the page
  • Fix CSS for the search box
  • Generate or add summaries of all docs pages

How to Test

Testing this locally really sucks because of CORs, where even once we allow CORs requests from docs to search it'll still be broken locally. So below I'll add to methods to test locally based on what you want:

Static search results: Good for styling the page or generic functionality

On line 53 of search.js add an assignment of this.searchResults to a static array. Such as:

this.searchResults = [{"ref":"/using-pulsar/packages/","score":3.02,"matchData":{"metadata":{"shellcheck":{"body":{"position":[[10626,10]]}}}}}];

Dynamic search results

If you need to actually have dynamic search results, you'll need to spin up a local instance of the search microservice.

So get the search microservice, with the most recent PR (which adds CORs), and change the domain it adds to just be res.append("Access-Control-Allow-Origin", "*"); to let localhost work.

Then start it up, and trigger the index of search results with a POST localhost:8080/reindex/docs

Then in this PR change this.api = http://localhost:8080/search/docs

Now you can properly test, bit of a pain, but is how I was able to get it working for making this PR.

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.

1 participant