Using Python



  • Download Python source-code using the following link:
    Python code
  • IDE to execute the Python source-code.

Steps to Execute Python

  1. Create a virtual environment using the following steps:

    • Open the downloaded source-code on the IDE and in terminal type python -m venv .venv
    • Activate the virtual environment using the following command:
    • Install all the required libraries using the following command:
      pip install -r requirements.txt
  2. Run the following command on the virtual environment to run the FastAPI.
    uvicorn main:app --reload

  3. Once the FastAPI is running, the following message will be shown in the terminal:

  4. Click on the IP-Address or the link as shown in previous step ( to start the FastAPI UI on the browser.

  5. Add /docs to the end of the URL as in the browser to use the FastAPI UI.

  6. In the FastAPI UI, click on the POST method for API pretext_update and click on Try it out.

  7. After clicking on the Try it out button, find the Request body. In the request body, replace the indexname, host(IP Address), port, username and password with the corresponding server credentials (for the indexname, add idx as prefix. If the collection has only two digits as the collection id, add a 0 in front of the collection id for Example idx056).

  8. Let the POST method run. Logs about the entity generated and the corresponding results can be seen on the terminal.

  9. Once the POST method has completed executing, find the list of JSON objects for the title, description and keywords as shown in the following example.

  10. After completing the execution of previous step , go to the SearchBlox Console > Manage Collection, look for the Collection which was used in step 7 and click on the search icon on that collection as show in the following example.

  11. Login into the search page as shown below:

  12. At the end of the search URL, add &debug=TRUE to open the metadata section.

  13. Search for the term ml_ and you will find the three entities as shown in the following example: