{"id":21430147,"url":"https://github.com/cuba-platform/rich-search-addon","last_synced_at":"2025-08-09T07:08:32.209Z","repository":{"id":92173625,"uuid":"126154641","full_name":"cuba-platform/rich-search-addon","owner":"cuba-platform","description":" Global Search CUBA Platform application component that will provide user ability to search many types of objects in one search field.","archived":false,"fork":false,"pushed_at":"2024-12-27T08:43:42.000Z","size":1319,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-12-27T09:29:12.266Z","etag":null,"topics":["apache2","cuba-component","cuba-platform","search"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cuba-platform.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-21T09:30:19.000Z","updated_at":"2020-03-23T09:15:48.000Z","dependencies_parsed_at":"2023-04-28T00:01:17.624Z","dependency_job_id":null,"html_url":"https://github.com/cuba-platform/rich-search-addon","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuba-platform%2Frich-search-addon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuba-platform%2Frich-search-addon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuba-platform%2Frich-search-addon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuba-platform%2Frich-search-addon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cuba-platform","download_url":"https://codeload.github.com/cuba-platform/rich-search-addon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235246885,"owners_count":18959324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache2","cuba-component","cuba-platform","search"],"created_at":"2024-11-22T22:21:00.370Z","updated_at":"2025-01-23T08:19:10.388Z","avatar_url":"https://github.com/cuba-platform.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp\u003e\n    \u003ca href=\"http://www.apache.org/licenses/LICENSE-2.0\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat\" alt=\"license\" title=\"\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://travis-ci.org/cuba-platform/rich-search-addon\"\u003e\u003cimg src=\"https://travis-ci.org/cuba-platform/rich-search-addon.svg?branch=master\" alt=\"Build Status\" title=\"\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Rich Search\n\n- [Overview](#overview)\n- [Installation](#installation)\n  - [From the Marketplace](#from-the-marketplace)\n  - [By Coordinates](#by-coordinates)\n- [Quick Start](#quick-start)\n- [Data Model](#data-model)\n- [Usage](#usage)\n- [Known Issues](#known-issues)\n\n## Overview\n\nThe add-on is designed to search for various types of objects using a single field. This out-of-the-box solution enables searching by application menu items.\n\nYou can configure your application to search for entities including related ones as well as entity attributes.\n\nKey features:\n- A single field for searching.\n- Customizable search strategy.\n\n\u003cimg src=\"https://github.com/cuba-platform/rich-search-addon/raw/master/resources/search.gif\" alt=\"Component image example\"/\u003e\n\nSee [sample application](https://github.com/cuba-platform/rich-search-addon-demo) using this add-on.\n\n# Installation\n\nThe add-on can be added to your project in one of the ways described below. Installation from the Marketplace is the simplest way. The last version of the add-on compatible with the used version of the platform will be installed.\nAlso, you can install the add-on by coordinates choosing the required version of the add-on from the table.\n\nIn case you want to install the add-on by manual editing or by building from sources see the complete add-ons installation guide in [CUBA Platform documentation](https://doc.cuba-platform.com/manual-latest/manual.html#app_components_usage).\n\n## From the Marketplace\n\n1. Open your application in CUBA Studio. Check the latest version of CUBA Studio on the [CUBA Platform site](https://www.cuba-platform.com/download/previous-studio/).\n2. Go to *CUBA -\u003e Marketplace* in the main menu.\n\n ![marketplace](img/marketplace.png)\n\n3. Find the Rich Search add-on there.\n\n ![addons](img/addons.png)\n\n4. Click *Install* and apply the changes.\nThe add-on corresponding to the used platform version will be installed.\n\n## By coordinates\n\n1. Open your application in CUBA Studio. Check the latest version of CUBA Studio on the [CUBA Platform site](https://www.cuba-platform.com/download/previous-studio/).\n2. Go to *CUBA -\u003e Marketplace* in the main menu.\n3. Click the icon in the upper-right corner.\n\n ![by-coordinates](img/by-coordinates.png)\n\n4. Paste the add-on coordinates in the corresponding field as follows:\n\n `com.haulmont.addon.search:search-global:\u003cadd-on version\u003e`\n\n where `\u003cadd-on version\u003e` is compatible with the used version of the CUBA platform.\n\n | Platform Version | Add-on Version |\n|------------------|----------------|\n| 7.2.X            | 1.6.0             |\n| 7.1.X            | 1.5.0             |\n| 7.0.X            | 1.4.0             |\n| 6.10.X           | 1.3.0             |\n| 6.9.X            | 1.2.0             |\n| 6.8.X            | 1.0.3             |\n\n5. Click *Install* and apply the changes. The add-on will be installed to your project.\n\n# Quick Start\n\n1. Override the main screen via the Studio interface.\n1. Add the following code to `ext-mainwindow.xml`:\n\n**For horizontal menu layout**\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?\u003e\n\u003cwindow xmlns=\"http://schemas.haulmont.com/cuba/window.xsd\"\n        class=\"com.company.rs.web.screens.ExtAppMainWindow\"\n        extends=\"/com/haulmont/cuba/web/app/mainwindow/mainwindow.xml\"\n        messagesPack=\"com.company.rs.web.screens\"\n        xmlns:ext=\"http://schemas.haulmont.com/cuba/window-ext.xsd\"\n        xmlns:search=\"http://schemas.haulmont.com/cuba/search.xsd\"\u003e\n    \u003cdialogMode height=\"600\"\n                width=\"800\"/\u003e\n    \u003clayout\u003e\n        \u003chbox id=\"titleBar\"\u003e\n            \u003csearch:richSearch id=\"search\"\n                               align=\"MIDDLE_LEFT\"\n                               ext:index=\"3\"\n                               inputPrompt=\"msg://search\"\n                               suggestionsLimit=\"200\"\u003e\n                \u003csearch:strategyBean name=\"search_MainMenuSearchStrategy\"/\u003e\n            \u003c/search:richSearch\u003e\n        \u003c/hbox\u003e\n    \u003c/layout\u003e\n\u003c/window\u003e\n```\n\n**For vertical menu layout**\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?\u003e\n\u003cwindow xmlns=\"http://schemas.haulmont.com/cuba/window.xsd\"\n        extends=\"/com/haulmont/cuba/web/app/main/main-screen.xml\"\n        messagesPack=\"com.haulmont.demo.richsearch.web.screens\"\n        xmlns:ext=\"http://schemas.haulmont.com/cuba/window-ext.xsd\"\n        xmlns:search=\"http://schemas.haulmont.com/cuba/search.xsd\"\u003e\n    \u003cdialogMode height=\"600\"\n                width=\"800\"/\u003e\n    \u003clayout\u003e\n        \u003chbox id=\"horizontalWrap\"\u003e\n            \u003cvbox id=\"sideMenuPanel\"\u003e\n                \u003cvbox ext:index=\"4\" margin=\"true\"\u003e\n                    \u003csearch:richSearch id=\"search\"\n                                       align=\"MIDDLE_LEFT\"\n                                       width=\"100%\"\n                                       inputPrompt=\"msg://search\"\n                                       suggestionsLimit=\"200\"\u003e\n                        \u003csearch:strategyBean name=\"search_SideMenuSearchStrategy\"/\u003e                        \n                    \u003c/search:richSearch\u003e\n                \u003c/vbox\u003e\n            \u003c/vbox\u003e\n        \u003c/hbox\u003e\n    \u003c/layout\u003e\n\u003c/window\u003e\n```\n\n# Data Model\n\n### Search Field\n\nSearch Field provides one or several search strategies that are called for each search query.\n\n### Search Strategy\n\nSearch Strategy defines which objects should be returned as a result of the current search request.\n\n### SearchEntry\n\nSearchEntry is an interface designed to work with search result objects. Each SearchEntry has an id, caption\nand the name of a search strategy that it belongs to specified.\n\n### DefaultSearchEntry\n\nDefaultSearchEntry defines the default implementation of SearchEntry.\n\n### SearchContext\n\nSearchContext provides the context dependent data for the search mechanism, e.g. a user session, additional params.\n\n### HeaderEntry\n\nHeaderEntry implements a header for grouping strategy results.\n\n\n# Usage\n\nLet us consider an example of how the component can be of use. Start by searching for a system user. The component finds\nthe required user and opens User Editor.\n\nThe system performs search by login. In order to configure the component, use the following code:\n\n```java\nLoadContext\u003cUser\u003e lc = LoadContext.create(User.class);\nlc.setQueryString(\"select u from sec$User u where u.loginLowerCase like concat('%',:loginLowerCase,'%')\")\n        .setParameter(\"loginLowerCase\", query.toLowerCase());\n```\n\nThe sections below present several options to define search strategies.\n\n### Using A Spring Bean As Search Strategy\n\n**Spring bean**:\n```java\n@Component(\"search_UsersSearchStrategy\")\npublic class UsersSearchStrategy implements SearchStrategy {\n    @Override\n    public List\u003cSearchEntry\u003e load(SearchContext context, String query) {\n        LoadContext\u003cUser\u003e lc = LoadContext.create(User.class);\n        lc.setQueryString(\"select u from sec$User u where u.loginLowerCase like concat('%',:loginLowerCase,'%')\")\n                .setParameter(\"loginLowerCase\", query.toLowerCase());\n\n        return dataManager.loadList(lc).stream()\n                .map(user -\u003e new DefaultSearchEntry(user.getId().toString(), user.getCaption(), name()))\n                .collect(Collectors.toList());\n    }\n\n    @Override\n    public void invoke(SearchContext context, SearchEntry value) {\n        LoadContext\u003cUser\u003e lc = LoadContext.create(User.class)\n                .setId(UuidProvider.fromString(value.getId()));\n        User user = dataManager.load(lc);\n        AppUI.getCurrent().getTopLevelWindow().openEditor(user, WindowManager.OpenType.NEW_TAB);\n    }\n\n\n    @Override\n    public String name() {\n        return \"usersSearchStrategy\";\n    }\n}\n```\n\n**XML screen config**:\n```xml\n\u003cwindow\n    class=\"com.company.test.web.screens.TestWindow\"\n    xmlns:search=\"http://schemas.haulmont.com/cuba/search.xsd\"\u003e\n    ...\n    \u003clayout\u003e\n        ...\n        \u003csearch:richSearch id=\"search\" inputPrompt=\"msg://search\"\u003e\n            \u003csearch:strategyBean name=\"search_UsersSearchStrategy\" /\u003e\n        \u003c/search:richSearch\u003e\n        ...\n    \u003c/layout\u003e\n    ...\n\u003c/window\u003e\n```\n\n**Localization**\n\nAdd the following entry to the main message pack as it is given below:\n```text\nsearchStrategy.{strategyName} = Strategy name\n```\nExample:\n```text\nsearchStrategy.usersSearchStrategy = Users\n```\n\n### Using Controller Methods\n\n**XML screen config**:\n```xml\n\u003cwindow\n    class=\"com.company.test.web.screens.MyWindowController\"\n    xmlns:search=\"http://schemas.haulmont.com/cuba/search.xsd\"\u003e\n    ...\n    \u003clayout\u003e\n        ...\n        \u003csearch:richSearch id=\"search\" inputPrompt=\"msg://search\"\u003e\n            \u003csearch:strategy name=\"usersSearchStrategy\" searchMethod=\"search\" invokeMethod=\"invoke\" /\u003e\n        \u003c/search:richSearch\u003e\n        ...\n    \u003c/layout\u003e\n    ...\n\u003c/window\u003e\n```\n\n**Screen controller**:\n```java\npublic class MyWindowController extends AbstractWindow {\n\n    @Inject\n    protected DataManager dataManager;\n\n    public List\u003cSearchEntry\u003e search(SearchContext context, String query) {\n        LoadContext\u003cUser\u003e lc = LoadContext.create(User.class);\n        lc.setQueryString(\"select u from sec$User u where u.loginLowerCase like concat('%',:loginLowerCase,'%')\")\n                .setParameter(\"loginLowerCase\", query.toLowerCase());\n\n        return dataManager.loadList(lc).stream()\n                .map(user -\u003e new DefaultSearchEntry(user.getId().toString(), user.getCaption(), \"usersSearchStrategy\"))\n                .collect(Collectors.toList());\n    }\n\n    public void invoke(SearchContext context, SearchEntry searchEntry) {\n        LoadContext\u003cUser\u003e lc = LoadContext.create(User.class)\n                .setId(UuidProvider.fromString(searchEntry.getId()));\n        User user = dataManager.load(lc);\n        AppUI.getCurrent().getTopLevelWindow().openEditor(user, WindowManager.OpenType.NEW_TAB);\n    }\n}\n```\n\n### Using Programmatic Strategy\n\n**Screen controller**:\n\n```java\npublic class MyWindowController extends AbstractWindow {\n\n    @Inject\n    protected DataManager dataManager;\n\n    @Inject\n    protected RichSearch search;\n\n    @Override\n    public void init(Map\u003cString, Object\u003e params) {\n        super.init(params);\n\n        search.addStrategy(\"usersSearchStrategy\", query -\u003e {\n            LoadContext\u003cUser\u003e lc = LoadContext.create(User.class);\n            lc.setQueryString(\"select u from sec$User u where u.loginLowerCase like concat('%',:loginLowerCase,'%')\")\n                    .setParameter(\"loginLowerCase\", query.toLowerCase());\n\n            return dataManager.loadList(lc).stream()\n                    .map(user -\u003e new DefaultSearchEntry(user.getId().toString(), user.getCaption(), \"usersSearchStrategy\"))\n                    .collect(Collectors.toList());\n        }, searchEntry -\u003e {\n            LoadContext\u003cUser\u003e lc = LoadContext.create(User.class)\n                    .setId(UuidProvider.fromString(searchEntry.getId()));\n            User user = dataManager.load(lc);\n            AppUI.getCurrent().getTopLevelWindow().openEditor(user, WindowManager.OpenType.NEW_TAB);\n        });\n    }\n}\n```\n\nThe result is:\n\n\u003cimg src=\"https://github.com/cuba-platform/rich-search-addon/raw/master/resources/users-search.gif\" alt=\"User search example\"/\u003e\n\n## Known issues\n\n1. The available amount of input should be accounted for each strategy separately (no task, to be discussed).\n1. It is required to add an XML declaration for specific strategy parameters (no task, to be discussed).\n1. It is required to add keyboard shortcuts for the component and its settings (no task, to be discussed).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuba-platform%2Frich-search-addon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcuba-platform%2Frich-search-addon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuba-platform%2Frich-search-addon/lists"}