-
Search server
To set up a search server, you have to make a indexer based on one of the indexing methods. Then you need to create a server that can give you the results from the queries, The one in this example uses debserach3 and searchbase and the aiohttp that comes with DEPy3 installation package.
from aiohttp import web from debsearch3.searchbase import SearchBase async def handle(request): search = request.app['search'] name = request.match_info.get('name', "") res = search.searchindex(name, 50) return web.json_response(res) app = web.Application() app.add_routes([web.get('/', handle), web.get('/{name}', handle)]) if __name__ == '__main__': searchroot = "C:\\\path\\to\\your\\search\\index\\root" searchname = "searchname" search = SearchBase(searchname, searchroot) app['search']=search web.run_app(app,port=8543)
This is a simple aiohttp setup with one handler that will take your search request. The search is set up when you start the server (after the if __name__ == '__main__':) and used for each call to the server. The searchroot and searchname must match the one used when creating the index. The port it is served from here is 8543 as set in web.run_app at the last line. This is what you must use when setting up the rewrite in the site setup in IIS.
To test your server, just run the script and write 127.0.0.1:8543/yourquery in your browser and it should respond with the results as json.
Add the server as a service
To make sure this server starts when you restart your server, you should set it up as a service. There is no tool added with the python installation that do that, but the deserver come with NSSM that will do just what we need. Here is how:
First I usually create a batch file with the instructions to start it all. This to make it easier to test that the command for startup actually work. It will also help if you need to add system variables or start a cleanup process before startup etc. All files to start up things for the Python library I would put in one place C:\ProgramData\DataEase\DEPy3 that is where the license of the library is stored. Next I like to save all my scripts for the application in the app folder in a scripts folder. Then my scripts will be updated by the deployment server if I use that.
@echo start my.server.domain search server "C:\DEPy3\python.exe" "C:\path\to\your\database\to\search\scripts\deserverdevsearchserver.py"
Ex.Start server batch file stored as my.domain.seach.server.bat in C:\ProgramData\DataEase\DEPy3
Next you need to add it to services using NSSM and give it a user with right to read the indexes and execute the python code.
C:\Program Files (x86)\DataEase\deserver\nssm install DES_MySearchServer You can skip the GUI by using C:\Program Files (x86)\DataEase\deserver\nssm install DES_MySearchServer C:\ProgramData\DataEase\DEPy3\my.domain.search.server.bat
Now you should find your batch file running as a service in Services with the name DES_MySearchServer. If you did not set up the user account with password to run it in, in NSSM gui you can do it now in services by right click and Properties under the Tab Log On