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

directus-extension-search-engine

v0.0.6

Published

search engine

Downloads

208

Readme

I. Setup Docker compose & Env

typesense:
    image: typesense/typesense:27.0.rc7
    container_name: typesense-search
    restart: always
    ports:
        - "8108:8108"
    volumes:
        - ./typesense-data:/data
    command: '--data-dir /data --api-key=$TYPESENSE_API_KEY --enable-cors'
TYPESENSE_API_KEY="112233"

II. Configs

Install

npm i directus-extension-search-engine

1. Field Engine Type

Allows to configure the type of search engine to be used

Note: currently I only support typesense, in the future I will support elasticsearch

2. Field Typesense API Key

This field is configured in env. Any change to the value in this field will be invalid.

3. Field Typesense Urls

This field specifies the URLs of the typesense service. These services must all share the same API key configured in env

4. Field Typesense Indexing

The processing flow here will be: get data in the query configured in query and collection, then process the data with Javascript in Function Parse so that the output matches the schema configured in Schema

4.1. Query data

In this step, we will get data with directus sdk query (collection & query). The returned response will be the input (data) of the Function Parse field to run the script.

See more: https://docs.directus.io/reference/items.html

4.2 Parse data & index schema

The above data will be put into Function Parse with the variable data and processed. The data needs to be processed to match the schema configured in the schema field.

Config schema: https://typesense.org/docs/0.25.2/api/collections.html#create-a-collection

III. Router search

1. Search with collection index

POST <CMS url>/search/typesense/search-collection/:collection

Authorization: <user token>

Params: collection

Body

{
  "q" : "stark",
  "query_by" : "title"
}

Body config: https://typesense.org/docs/0.25.2/api/search.html#query-parameters

Docs: https://typesense.org/docs/0.25.2/api/search.html

2. Multi-search

POST <CMS url>/search/typesense/multi-search

Authorization: <user token>

Query params

{
    "query_by": "name",
}

Note: query params will be used as commonSearchParams in typesense (https://typesense.org/docs/0.25.2/api/federated-multi-search.html#multi-search-parameters)

Body

{
  "q" : "stark",
  "query_by" : "title"
}

Note: this body will be used as searchRequests in typesense (https://typesense.org/docs/0.25.2/api/federated-multi-search.html#multi-search-parameters)

Body config: https://typesense.org/docs/0.25.2/api/search.html#query-parameters

Docs: https://typesense.org/docs/0.25.2/api/search.html

3. Re-index data (Clear and re-index)

POST <CMS url>/search/typesense/refresh-index

Authorization: <admin token>

4. Data Indexing (with collections)

POST <CMS url>/search/typesense/index-data

Authorization: <admin token>

Body

{
  "collections": ["news"]
}

Note: If collections does not receive a value or the value is incorrect, collections will be assigned all configured values.

5. Clear data index (with collections)

POST <CMS url>/search/typesense/clear-collections

Authorization: <admin token>

Body

{
  "collections": ["news"]
}