首页 > 其他分享 >Typesense

Typesense

时间:2023-06-03 17:12:55浏览次数:19  
标签:docusaurus __ Typesense -- menu contains article

Usage

cat > docker-compose.yml <<-'EOF'
# https://hub.docker.com/r/typesense/typesense
# Port: 8108
version: "3"

services:
  typesense:
    image: typesense/typesense:0.24.1
    command: '--data-dir /data/ --api-key=<password> --enable-cors'
    network_mode: host
    restart: always
    volumes:
      - $PWD/typesense/data/:/data/

EOF
# <password> is the password for the API key

Start

docker-compose up --detach

Stop

docker-compose down

Scraper

# https://typesense.org/docs/guide/docsearch.html#run-the-scraper
docker run -it \
    --rm \
    --env "CONFIG=$(cat ./docusaurus-2.json | jq -r tostring)" \
    --env-file=.env \
    typesense/docsearch-scraper

.env

TYPESENSE_API_KEY=password
TYPESENSE_HOST=192.168.31.49
TYPESENSE_PORT=8108
TYPESENSE_PROTOCOL=http

docusaurus-2.json

{
    "index_name": "docusaurus-2",
    "start_urls": [
        "https://docusaurus.io/"
    ],
    "sitemap_urls": [
        "https://docusaurus.io/sitemap.xml"
    ],
    "sitemap_alternate_links": true,
    "stop_urls": [
        "/tests"
    ],
    "selectors": {
        "lvl0": {
            "selector": "(//ul[contains(@class,'menu__list')]//a[contains(@class, 'menu__link menu__link--sublist menu__link--active')]/text() | //nav[contains(@class, 'navbar')]//a[contains(@class, 'navbar__link--active')]/text())[last()]",
            "type": "xpath",
            "global": true,
            "default_value": "Documentation"
        },
        "lvl1": "header h1",
        "lvl2": "article h2",
        "lvl3": "article h3",
        "lvl4": "article h4",
        "lvl5": "article h5, article td:first-child",
        "lvl6": "article h6",
        "text": "article p, article li, article td:last-child"
    },
    "strip_chars": " .,;:#",
    "custom_settings": {
        "separatorsToIndex": "_",
        "attributesForFaceting": [
            "language",
            "version",
            "type",
            "docusaurus_tag"
        ],
        "attributesToRetrieve": [
            "hierarchy",
            "content",
            "anchor",
            "url",
            "url_without_anchor",
            "type"
        ]
    },
    "conversation_id": [
        "833762294"
    ],
    "nb_hits": 46250
}

标签:docusaurus,__,Typesense,--,menu,contains,article
From: https://www.cnblogs.com/newhappy98/p/17392690.html

相关文章

  • typesense
    TypesenseUsagecat>docker-compose.yml<<-'EOF'#https://typesense.org/docs/guide/install-typesense.html#from-the-docker-image#Port:8108version:"3"s......