Narcissistic, Perfectly Modest
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

@craftercms/search

1.0.0 • Public • Published

@craftercms/search

This package contains tools for integrating your application with Crafter Search.

Usage

  • Install module using yarn or npm
    • Yarn: yarn add @craftercms/search
    • npm: npm install @craftercms/search
  • Import and use the service(s) you need

Services


Search

Returns the result for a given query.

search(query: Query)

Parameters
query The query object
config Crafter configuration. Optional. Default value in here.

Returns

Map model

Examples

  • Connect to Crafter Search to query for content:
  import { crafterConf } from '@craftercms/classes';
  import { SearchService } from '@craftercms/search';
 
  //First, set the Crafter configuration to _cache_ your config. 
  //All subsequent calls to `getConfig` will use that configuration.
  crafterConf.configure({
    baseUrl: 'http://localhost:8080'
    site'editorial'
  })
 
  SearchService
    .search({
        query: '*:*',
        filterQueries: ['content-type:"/page/article"', 'featured_b:true']
      })
    .subscribe(results => {
      // ...
    });

You may alternatively use a different config by supplying the config object at the service call invoking time

  import { SearchService } from '@craftercms/search';
 
  //Create query
  const query = SearchService.createQuery();
  query.query = "*:*";
  query.filterQueries = ['content-type:"/component/video"'];
 
  SearchService
    .search(query, {
      baseUrl: 'http://localhost:8080',
      site: 'editorial'
    })
    .subscribe(results => {
      // ...
    });

install

npm i @craftercms/search

Downloadsweekly downloads

86

version

1.0.0

license

GNU LGPL 3.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
Report a vulnerability