Giter Site home page Giter Site logo

lgdd / liferay-external-searches Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 85 KB

An example on how to build a configurable widget to trigger external searches along with Liferay search to Elasticsearch.

License: MIT License

Java 100.00%
liferay liferay-portal liferay-dxp

liferay-external-searches's Introduction

Liferay External Searches

An example on how to build a configurable widget to trigger external searches along with Liferay search to Elasticsearch.

preview

Getting Started

You can either:

  • Clone this repo
  • Run ./gradlew initBundle deploy

Or:

  • Download the modules from the release page
  • Unzip the Java 8 or 11 version.
  • Move the JARs to the deploy folder under your Liferay home.

Once the 3 modules (external-search-api, external-search-service and external-search-results-web) are deployed:

  • Go to the Liferay page where search results are displayed (default: /search)
  • Add the widget External Search Results (under the Search category)
  • Click on Configure an external search engine to be used.
  • Select an External Search Engine from the dropdown list (default options: Reddit, Stack Overflow, Wikipedia)
  • Click Save
  • If the search page is a Content Page, click Publish.

Now when you run a search in Liferay, you should see results from the search engine selected in its own widget.

You can repeat this process and add more instances of the widget External Search Results with different configurations.

Going Further

Search Options

In the configuration, you can find a textarea for Search Options. This is a list of search options to fill as a key-value pairs (one per line). The supported options are search engine dependents, so you need to refer to each external search documentation (e.g. Stack Exchange Search API).

Display Template

This widget supports Application Display Templates (ADT), also called Widget Templates.

By default, you'll find 3 templates:

If you take a look at them, you'll notice that you can have more information than the name and URL of each search result. A map of metadata can be associated with each type of search result. For example to retrieve and display the tags associated with a Stack Overflow topic.

More Searches

If you clone this repo, you can try to add more external search sources in the external-search-service module.

The process is pretty simple and straightforward:

  • Create a new class
  • Annotate with @Component
  • Add a service attribute to the @Component with the value ExternalSearch.class
  • Add a property attribute to the @Component with the value engine= followed by the same of the source
  • Extends BaseExternalSearch and implements required methods

Checkout the RedditService class as an example.

In some cases, you might want to override the search methods. For example, the WikipediaService supports localization and overriding the search methods is needed to pass the right domain prefix depending on the language.

Feedback & Contribution

Feel free to open issues if you have any question/suggestion or pull requests if you want to contribute.

License

MIT

liferay-external-searches's People

Contributors

lgdd avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.