The Search Module

image showing a mobile phone and apps

Description

The Search module provides a backend search service for the MoboSearch project, using also the json information in the App Interchange Format.

Installation

The backend search service is derived from OpenSearch, so first you need to install it. After that, you should install ‘Node.js’ and ‘npm’ in your system. After that, you should install ‘Node.js’ and ‘npm’ in your system. Once these packages have been installed you can proceed to download the code and install its dependencies by running npm install. At this point, you can launch a server on localhost:9000 (localhost, port 9000) that exposes an endpoint in /search allowing clients to perform searches.

Quick usage

The backend search service is composed of two modules: search web server and search utility functions.

The search web server exposes an endpoint in /search; clients can query it including the mandatory parameter text. The result of this request is a list of applications that contains the searched text in the title or in the description, sorted using the selected privacy score. Clients can specify additional parameters such as size and page to receive a fixed amount of results for each page.

The search utility functions are a set of utilities made to allow an easy search management. Specifically, with these utilities you can create a new index, delete an existing index, list indices, get indices status, add documents to an index, remove documents and retrieve documents.

Options

The script index is used to manage the indexes:

    Command line: index
    -h —help        show this help message and exit
    -a —action      action to perform between: “create”, “delete”, “get” and “check”
    -n —name        index name
  
In particular:
./index --action "create" --name "name"
Creates a new index.
./index --action "delete" --name "name"
Deletes the existing index.
./index --action "get" --name "name"
Gets information about the existing index.
./index --action "check" --name index_name
Checks the index status.

The other script, document is used to manage documents within an index:

    Command line: document
    -h —help        show this help message and exit
    -a —action      action to perform between: “index”, “delete”, and “get”
    -n —index_name  index name
    -i —id          id of the document
    -d —dir         files directory to add
  
In particular:
./document --action "index" --index_name "name" file_path
Index a new document by passing its path.
./document --action "index" --index_name "name" --dir directory
Index new documents by passing a directory path.
./document --action "delete" --index_name "name" --id "id"
Delete a document from the index (by id).
./document --action "get" --index_name "name" --id "id"
Get a particular document (by id).

Live Demo

There is a live demo of the search module (with a bare-minimum demo layout: that will be of course completely refined, both aestetically and textually, when launching the full web site) online at http://test.mobosearch.top/.

The Code

The source code of the module can be directly downloaded here (note that at public launch we will also provide a GitHub link), as well as the templates used to generate the online demo (used by JsonWeb, together with the selected app data in AIF format, to automatically generate the website).