Set up search with StreamX and AEM
In this tutorial we will set up StreamX search with AEM used for datasource. We will use the We.Retail sample application and content which comes pre-installed with non-production AEM author installations.
Prerequisites
To complete this tutorial, you will need:
-
roughly 15 minutes
-
A running instance of
AEM author 6.5
instance with at leastService Pack 6.5.17
installed, and also with the out-of-the-box We.Retail sample application and content.
If you have an author instance that wasn’t started with the nosamplecontent run mode,
you can safely assume that you have this installed.
You can validate the installation of We.Retail
by visiting We.Retail landing page in the English master.
If it returns a 404 , then you don’t have a proper We.Retail installation.
In this case, please use another (for example a new & fresh) AEM author instance.
|
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: Install StreamX OSGi bundles and configuration
To integrate AEM with StreamX you must install StreamX OSGi bundle with all the necessary OSGi dependencies and configuration. Installed and configured OSGi bundle enable feeding StreamX Mesh with AEM sourced data. Follow the steps below to install the package:
-
Upload and install
aem-with-streamx-tutorials/streamx-aem.all-1.0.2.zip
from the cloned project repository
Step 3: Run the StreamX Mesh
-
Open the terminal and go to
search-with-streamx-and-aem-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.yml -------------------------------------------------------------------
Step 4: Publish content from AEM
At this point we are ready to push content into the StreamX Service Mesh.
Because of the proper StreamX Connector
OSGi bundles and OSGi configuration installed,
content ingestion simply means the good old activation/publication/replication we are used to.
On replication events, the `StreamX Connector`s takes care of collecting and sending the content
to the StreamX Service Mesh.
-
Visit AEM author - Sites admin page - We.Retail United States
-
Select page
/content/we-retail/us
and from the top menu, click on Manage Publication -
On the next screen (Options) leave the defaults and proceed with Next
-
Action : Publish
-
Scheduling : Now
-
-
On the next screen (Scope) click on the thumbnail of the
/content/we-retail/us
item which will reveal the Include Children option -
Click on the Include Children item and deselect every checkbox, then confirm your changes by clicking on Add
-
Finally, click on Publish
-
Wait for AEM author to complete the publication
In the background, AEM sends the published content to the StreamX Service Mesh, which feeds data to the search service.
Step 5: Search content with StreamX
The search service defined and already started within the StreamX Service Mesh listens at http://localhost:8082/search
.
-
Search for Equipment and limit the results to 40 items, executing the following command in the terminal:
curl -s 'http://localhost:8082/search/byQuery?size=40&query=equipment*' -H 'Accept: */*' --insecure | jq '.hits.hits | length'
As the result, you should see the number
40
, indicating that we received at least 40 hits across all We.Retail pages. The plain output of the search service is not easy to read, so we’ve usedjq
to count the number of matches for easier understanding.
Step 6: Update content
Now let’s update AEM content and see how it reflects in the search service.
-
First, verify that we don’t have any hit for the search term StreamX: execute the following command and verify its output is
0
curl -s 'http://localhost:8082/search/byQuery?size=40&query=streamx*' -H 'Accept: */*' --insecure | jq '.hits.hits | length'
-
Open up the edit dialog of the Title component (under the Hero Image) saying Welcome our finest equipment and replace Welcome our finest equipment with Hello StreamX from AEM!
-
Confirm your changes on the edit dialog
-
Use the Rollout Page option from the page action bar, and roll out to the two existing live copies
-
Use the Publish Page option from the page action bar
-
Finally, execute the search again:
curl -s 'http://localhost:8082/search/byQuery?size=40&query=streamx*' -H 'Accept: */*' --insecure | jq '.hits.hits | length'
You should see a JSON message with a single entry, meaning that our just-updated content was found to be a match by StreamX.