npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jahia/search-ui-jahia-connector

v2.0.13

Published

A Search UI connector for Jahia GraphQL Search API

Downloads

17

Readme

Jahia Search UI Connector

screenshot

Installation

In order to use Search UI Jahia Connector, you simply need to add the "@jahia/search-ui-jahia-connector": "^1.0.0" package to the list of dependencies in your package.json

Then import the relevant components (described in detail below) in your app

Usage

Interfacing with Jahia's GraphQL Search API is done by instantiating the JahiaSearchAPIConnector object.

The following functionality is currently implemented:

  • onSearch
  • onAutocomplete
  • Sort

Options

The following configuration is required in order for the custom request/response adaptors to work

| Param | Type | Description | | --------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------- | | apiToken* | string | Jahia GraphQL API token | | baseURL* | string | URL for Jahia server | | siteKey* | string | Identifies which site search will be performed in | | language* | string | The language in which to perform the search | | workspace* | string | Specifies which workspace to perform search in LIVE or DEFAULT | | nodeType* | string | Indexed document type to filter by (defaults to jnt:page) |

Result Field Configuration

Fields in result set are determined by a list of instantiated Field object

| Param | Type | Description | | --------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------- | | type* | FieldType | The type of field to return from search | | name* | string | The JCR property name to retrieve | | alias | string | Alternate name to be used in response | | useSnippet | string | Field rendering type; snippet (HTML) or raw (Plain text) |

Facet Configuration

There are 3 types of facets currently supported

  • Term
  • Range
  • Date Range
Facet Object Configuration

| Param | Type | Description | | --------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------- | | type* | string | Type of facet [value|range|date_range] | | disjunctive | boolean | AND[false] or OR[true] operation | | ranges** | Array | Array of range objects described below |

ranges field is required for Date/Number range facet. Below is the structure:

 let rangeExample = {
   //Label used for this range (required)
   name: 'jcr:lastModified',
   //At least `from` or `to` is required
   //Optional
   from: 'now-1M',
   //Optional
   to: 'now'
 }

Note date_range value can be a date string or date math expression i.e now-1M

Example

By following the guidelines below, you will be able to use JahiaSearchAPIConnector in your Search UI app. example_results

Import the require classes to be used in Search UI's SearchProvider

import JahiaSearchAPIConnector, {Field, FieldType} from '@jahia/search-ui-jahia-connector';
...

Instantiate the connector by providing the configuration of your server and search results.

Note* for testing purposes we will provide a fake string for apiToken. See connection options for how to generate the token.

let connector = new JahiaSearchAPIConnector({
        apiToken: 'none',
        baseURL: 'http://localhost:8080',
        siteKey: 'digitall',
        language: 'en',
        workspace: 'LIVE',
        nodeType: 'jnt:page'
    });

Instantiate a list of fields to be returned from the search query

let fields = [
    new Field(FieldType.HIT, 'link'),
    new Field(FieldType.HIT, 'displayableName', 'title'),
    new Field(FieldType.HIT, 'excerpt', null, true),
    new Field(FieldType.NODE, 'jcr:created', 'created')
    ...
];

Facets are configured by using the following structure

let facets = {
  // Term Range Facet
  'jcr:keywords': {
    type: 'value',
    disjunctive: true
  },
  // Date Range Facet
  'jcr:lastModified': {
      type: 'date_range',
      disjunctive: true,
      ranges: [
        {
          from: 'now-1w',
          to: 'now',
          name: 'Last Week'
        },
        {
          from: 'now-1M',
          to: 'now',
          name: 'Last month'
        },
        {
          from: 'now-6M',
          to: 'now',
          name: 'Last 6 months'
        },
        {
          from: 'now-1y',
          to: 'now',
          name: 'Last year'
        }
      ]
  }
}

Define the configuration object for Search UI's SearchProvider components

let config = {
        searchQuery: {
            //Set defined fields for search query
            result_fields: fields,
            facets: facets
        },
        autocompleteQuery: {
            results: {
                resultsPerPage: 10,
                //Set defined fields for autocomplete query
                result_fields: fields
            }
        },
        //Set the JahiaSearchAPIConnector connector that was defined above
        apiConnector: connector,
        hasA11yNotifications: true
    }

At this point you should have all bricks necessary to successfully use Jahia's Search UI Connector.