This version is still in development and is not considered stable yet. For the latest stable version, please use StreamX Guides 1.1.0! |
Set up search with StreamX
Site search is a common requirement nowadays. However, maintaining search capabilities becomes more difficult when, in addition to authorable content, the search must include data from other systems such as PIM or e-commerce.
With StreamX, you can automate the integration and indexing of site content, regardless of the source, reducing the need for manual maintenance of search capabilities. As a result, users experience more reliable and timely search results, enabling them to find the latest information quickly and accurately.
This tutorial covers the following topics:
-
Setting up and running StreamX Mesh to enable search functionality.
-
Publishing content to be indexed and making it searchable.
-
Querying search results to verify content discoverability.
-
Unpublishing content and observing real-time updates in search results.
Prerequisites
To complete this guide, you will need:
-
Roughly 10 minutes
-
A web browser of your choice
Verify that no other StreamX instance or any other application that uses ports 8080, 8081 and 8082 is running. |
Step 1: Get the source files
Clone the Git repository containing source files for the example:
git clone https://github.com/streamx-dev/streamx-docs-resources.git
Step 2: Run the StreamX Mesh
We are about to run a Mesh that contains a service extracting indexable data from the ingested data. This indexable data is passed to a delivery service that is responsible for feeding the search service.
In this tutorial, the delivery service communicates with Opensearch started inside the same StreamX Mesh.
-
Open the terminal and go to
set-up-search-tutorial
inside the cloned project directory. -
Run the StreamX Mesh by using the following command:
streamx run
-
Wait for the following output:
------------------------------------------------------------------- STREAMX IS READY! ------------------------------------------------------------------- ... ------------------------------------------------------------------- Network ID: ... Mesh configuration file: ./mesh.yaml -------------------------------------------------------------------
Step 3: Feed StreamX with content for indexing
-
Publish the
index.html
page by using the following command:streamx publish -s 'content.bytes=file://site/index.html' pages index.html
-
Open your web browser and go to http://localhost:8081.
-
Verify accessibility of the
index.html
page. -
Then go to http://localhost:8082/search/query?query=greetings in your web browser.
-
Verify that the search results include an entry for the
index.html
page. -
Publish the
blog/entry.html
page by using the following command:streamx publish -s 'content.bytes=file://site/blog/entry.html' pages blog/entry.html
-
Visit http://localhost:8082/search/path?path=blog/entry.html in your web browser.
-
Ensure that the search results contain an entry for the
blog/entry.html
page. -
Visit http://localhost:8082/search/query?query=blog in your web browser.
-
Verify that the phrase search results include an entry for the
blog/entry.html
page.
Step 4: Unpublish the content and observe the search update
-
Unpublish the
blog/entry.html
page by using the following command:streamx unpublish pages blog/entry.html
-
Visit http://localhost:8082/search/path?path=blog/entry.html in your web browser.
-
Verify whether the entry for
blog/entry.html
disappears. -
Check if the entry for
blog/entry.html
also disappears.
Summary
Congratulations! You have learned how to set up site search with StreamX to streamline dynamic content management.