Tuesday, July 7, 2020

How to configure collections in Adobe Search and Promote to support multiple environments through same account?

This tutorial explains the details on how to configure search collection in Adobe Search and Promote to support multiple environments through same account.

Collection in Search and Promote

The collections can be used to allow customers to search specific areas of a website so that they can quickly find what they are looking for.
For example, customers can search a collection of URLs that are related to product sales or to support services.
Each collection is specified on a single line with a name and a URL mask. A URL mask can consist of the following:
• a full path such as 
• a partial path such as 
• a regular expression
To make a mask a regular expression, you insert the keyword regexp between the collection name and the URL mask e.g FAQs regexp ^.*/faqs
The IndexConnector URL entry points can be referenced to the collection as below
QA regexp index:test-feed*
Each line in the Collections field can contain only one URL mask. However, you can specify multiple URL masks for the same collection name on different lines.
The collection=<Collection Name> e.g. collection=Support parameters specifies the collection to use for the search.This parameter maps to the sp_k backend search parameter, sp_k=<Collection Name> e.g. sp_k=Support

Configuring Collection

One of the best scenario to use the collection is indexing the data for multiple environments e.g QA, UAT etc into a same Adobe Search and Promote account, the collection parameters can be used to search the documents specific to the environment.
I am using the IndexConnector as a URL entry point to index the data through XML feed files but the URL entry points can be a website URL with links.
Refer the below URL for more details on configuring Index Connector.
Refer the below URL for details on enabling custom JSON presentation and Transport templates
Let us now configure the collections to support QA and UAT environments search through same Search and Promote account.
As a first step configure the index connector for both QA and UAT environments with environment specific feed file.
product_QA.xml
<feed xmlns:xs="" version="2.0">
 <channel>
  <title>Product Feed</title>
  <Item>
   <link></link>
   <title>
   <![CDATA[Book Prod1 Title]]>
   </title>
   <description>
   <![CDATA[<p>Prod1 description</p>]]>
   </description>
   <productType>Book</productType>
   <ProductId>prod1</ProductId>
   <imageUrl>/content/dam/Images/product/prod1.jpg</imageUrl>
  </Item>
  <Item>
   <link></link> 
   <title>
   <![CDATA[Book Prod2 title]]>
   </title>
   <description>
   <![CDATA[<p>Prod2 description</p>]]>
   </description>
   <productType>Book</productType>
   <ProductId>prod2</ProductId>
   <imageUrl>/content/dam/Images/product/prod2.jpg</imageUrl>
  </Item><Item>
   <link></link>
   <title>
   <![CDATA[Watch Prod3 Title]]>
   </title>
   <description>
   <![CDATA[<p>Prod3 description</p>]]>
   </description>
   <productType>Watch</productType>
    <size>10</size>
   <ProductId>prod3</ProductId>
   <imageUrl>/content/dam/Images/product/prod3.jpg</imageUrl>
  </Item>
  <Item>
   <link></link>
   <title>
   <![CDATA[Watch Prod4 Title]]>
   </title>
   <description>
   <![CDATA[<p>Prod4 description</p>]]>
   </description>
   <productType>Watch</productType>
    <size>20</size>
   <ProductId>prod4</ProductId>
   <imageUrl>/content/dam/Images/product/prod4.jpg</imageUrl>
  </Item>
  </channel>
</feed>
product_UAT.xml
<feed xmlns:xs="" version="2.0">
 <channel>
  <title>Product Feed</title>
  <Item>
   <link></link>
   <title>
   <![CDATA[Book Prod1 Title]]>
   </title>
   <description>
   <![CDATA[<p>Prod1 description</p>]]>
   </description>
   <productType>Book</productType>
   <ProductId>prod1</ProductId>
   <imageUrl>/content/dam/Images/product/prod1.jpg</imageUrl>
  </Item>
  <Item>
   <link></link> 
   <title>
   <![CDATA[Book Prod2 title]]>
   </title>
            <description>
   <![CDATA[<p>Prod2 description</p>]]>
   </description>
   <productType>Book</productType>
   <ProductId>prod2</ProductId>
   <imageUrl>/content/dam/Images/product/prod2.jpg</imageUrl>
  </Item><Item>
   <link></link>
   <title>
   <![CDATA[Watch Prod3 Title]]>
   </title>
   <description>
   <![CDATA[<p>Prod3 description</p>]]>
   </description>
   <productType>Watch</productType>
            <size>10</size>
   <ProductId>prod3</ProductId>
   <imageUrl>/content/dam/Images/product/prod3.jpg</imageUrl>
  </Item>
  <Item>
   <link></link>
   <title>
   <![CDATA[Watch Prod4 Title]]>
   </title>
   <description>
   <![CDATA[<p>Prod4 description</p>]]>
   </description>
   <productType>Watch</productType>
             <size>20</size>
   <ProductId>prod4</ProductId>
   <imageUrl>/content/dam/Images/product/prod4.jpg</imageUrl>
  </Item>
  </channel>
</feed>
Enable the IndexConnector for both QA and UAT data feeds, Settings → Crawling →Index Connector
Adobe-search-and-promote-collections
Adobe-search-and-promote-collections
Image for post
Add the IndexConnector configurations to the URL entry points, Setting → Crawling → URL Entrypoints, the URL entry points can be configured as environment specific URL’s instead of IndexConnector
e.g
https://uat.example.com/search_index.html
https://qa.example.com/search_index.html
Adobe-search-and-promote-collections
Configure the collection Settings → Searching → Collections, the collection can be also configured as environment specific URL masks
e.g.
UAT https://uat.example.com/products
QA https://qa.example.com/products
Adobe-search-and-promote-collections
The configurations are ready, let us now run a Stage indexing (note the configuration are not pushed to live yet)
Index →Full Index →Staged Index →Run Full Index
Image for post
The collections can be tested through collection page “Test Collections” option
Adobe-search-and-promote-collections
Specify the search index URL, the index URL can be taken from Reports → Data Views →Default View, for index connector the URL is formed based on the primary key defined in IndexConnector definition(our case product id)
Image for post
Adobe-search-and-promote-collections
Adobe-search-and-promote-collections
Let us now fetch the search result through URL
URL to fetch all the data with out specifying the collection name — 
This will display the data from both collection(QA and UAT)
Adobe-search-nd-promote-collections
The URL to fetch the data specific to UAT, this will return the data specific to UAT collection
Image for post
Adobe-search-and-promote-collections
The URL to fetch the data specific to QA, this will return the data specific to QA collection
Image for post
Image for post
The configuration can be pushed live after successful validation and run a live index, Index →Full Index →Live Index →Run Full Index
The search collection can be used to enable the user to search on a specific section of the website e.g products, materials etc . The collection functionality can be also used to enable the search functionality for different environments(e.g QA and UAT) in the same Adobe Search and Promote Account.


Friday, July 3, 2020

How to access the local files externally through ngrok and python HTTP Server?

This tutorial explains how to share or access the local files externally through ngrok and Python http server.
I have the below two scenarios
  • a set of files that needs to be shared outside
  • share a simple website externally
The above scenarios can be achieved through Apache Server and external DNS configurations but require more configurations efforts.
  • ngrok free or paid version
  • Python latest version
Let us see how to enable the above scenarios through ngrok and python HTTP server with minimal configuration effort.
As a first step download ngrok(ngrok.com) for the required OS and extract the files
ngrok
ngrok
The ngrok allows you to expose a webserver running on your local machine to the internet. Just tell ngrok what port your web server is listening on.
On the free plan, ngrok’s URLs are randomly generated and temporary. If you want to use the same URL every time, you need to upgrade to a paid plan so that you can use the subdomain option for a stable URL. There are different paid plans they will provide some advance features like custom/reserved domains and multiple tunnels etc
ngrok

How ngrok works

You download and run a program on your machine and provide it the port of a network service, usually a web server.
It connects to the ngrok cloud service which accepts traffic on a public address and relays that traffic through to the ngrok process running on your machine and then on to the local address you specified.
ngrok

Python HTTP Server


Python standard library comes with an in-built webserver which can be invoked for simple web client server communication
The required port number can be assigned and the web server is accessed through this port
My system has python version 3.7.0 installed— “py -vi”
In the first scenario, i want to share some regular files externally
share files externally through ngrok and python http server
To start the HTTP server, cd to to the folder that should be shared(C:\Albin\blogData\demo\Share) through command prompt and execute the command “py -m http.server 80” — change the port number as required
share files externally through ngrok and python http server
Now the files are accessible through localhost
share files externally through ngrok and python http server

Let's now start ngrok to share this folder externally, cd to the folder where ngrok was extracted(C:\Albin\SW\ngrok-stable-windows-amd64)
Execute “ngrok.exe http 80”(80 is where python HTTP server running)
share files externally through ngrok and python http server
Now the external requests(http/https) are forwarded to localhost webserver through ngrok proxy domain
share files externally through ngrok and python http server

The local folders can be shared directly without a HTTP server through inbuilt ngrok file server. To share the local folder directly through ngrok , as a first step configure the authtoken to the ngrok

The authtoken can be retrieved through ngrok dashboard — the user should signup for a account , copy the command to set the authtoken by navigating to the dashboard.

Execute the command

ngrok-auth-token

Start the ngrok process — e.g ngrok http “file:///C:\Albin\blogData\demo\blogproject.blogproject

ngrok-auth-token

Now the files under the specific folder is accessible externally

ngrok-auth-token
Let us now see how to enable the second scenario, to access simple website externally, created a index.html file along with some test files into a folder(C:\Albin\blogData\demo\site), cd to the folder where the index.html and other files are located
share files externally through ngrok and python http server
Re-start the HTTP server, the pages are now accessible outside
share files externally through ngrok and python http server
The traffic can be monitored through the following URL — http://127.0.0.1:4040
share files externally through ngrok and python http server
The ngrok and python HTTP server can be used to share the local files externally without much effort and configurations.