Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

Cloudflare + OpenSearch + Lambdaで始める全文検索開発入門

amotz
October 05, 2021

Cloudflare + OpenSearch + Lambdaで始める全文検索開発入門

Developers.IO 2021 Decade で発表した資料です

amotz

October 05, 2021
Tweet

More Decks by amotz

Other Decks in Technology

Transcript

  1. %PDLFS*NBHFΛར༻ͨ͠0QFO4FBSDIߏங  version: '3' services: opensearch: image: opensearchproject/opensearch:1.0.1 container_name: opensearch

    environment: - cluster.name=docker-cluster - node.name=os-node - cluster.initial_master_nodes=os-node - bootstrap.memory_lock=true - http.host=0.0.0.0 - transport.host=127.0.0.1 - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" - "plugins.security.disabled=true" ulimits: memlock: soft: -1 hard: -1 volumes: - $PWD/.local/opensearch:/usr/share/opensearch/data ports: - 9200:9200 networks: - sandbox networks: sandbox: docker-compose.yml
  2. %PDLFS*NBHFΛར༻ͨ͠0QFO4FBSDIߏங  version: '3' services: opensearch: image: opensearchproject/opensearch:1.0.1 container_name: opensearch

    environment: - cluster.name=docker-cluster - node.name=os-node - cluster.initial_master_nodes=os-node - bootstrap.memory_lock=true - http.host=0.0.0.0 - transport.host=127.0.0.1 - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" - "plugins.security.disabled=true" ulimits: memlock: soft: -1 hard: -1 volumes: - $PWD/.local/opensearch:/usr/share/opensearch/data ports: - 9200:9200 networks: - sandbox networks: sandbox: docker-compose.yml ࠓճ͸ݕূͷͨΊ ηΩϡϦςΟϓϥάΠϯΛແޮԽ
  3. %PDLFS*NBHFΛར༻ͨ͠0QFO4FBSDIߏங  $ docker-compose up -d .. Creating network “local_sandbox"

    with the default driver Creating opensearch ... done Creating opensearch-dashboards ... done
  4. $MPVEqBSFEΛىಈͯ͠0QFO4FBSDIΛ֎෦ެ։  $ cloudflared tunnel --url localhost:9200 INF Requesting new

    quick Tunnel on trycloudflare.com... INF +---------------------------------------------------------------+ INF | Your quick Tunnel has been created! Visit it at (it may take some time to be reachable): | INF | https://female-attract-average-join.trycloudflare.com | INF +---------------------------------------------------------------+ ..
  5. $MPVEqBSFEΛىಈͯ͠0QFO4FBSDIΛ֎෦ެ։  $ cloudflared tunnel --url localhost:9200 INF Requesting new

    quick Tunnel on trycloudflare.com... INF +---------------------------------------------------------------+ INF | Your quick Tunnel has been created! Visit it at (it may take some time to be reachable): | INF | https://female-attract-average-join.trycloudflare.com | INF +---------------------------------------------------------------+ .. ϥϯμϜʹੜ੒͞Εͨ63-͕ ׂΓ౰ͯΒΕΔ
  6. -BNCEBͷιʔείʔυྫʢ/PEFYʣ  const { Client } = require('@opensearch-project/opensearch'); const OPENSEARCH_ENDPOINT

    = process.env.OPENSEARCH_ENDPOINT || ""; const client = new Client({ node: OPENSEARCH_ENDPOINT }); exports.handler = async (event) => { const result = await client.search({ index: 'devio_sample', pretty: true }); return result; }; /index.js
  7. -BNCEBͷιʔείʔυྫʢ/PEFYʣ  const { Client } = require('@opensearch-project/opensearch'); const OPENSEARCH_ENDPOINT

    = process.env.OPENSEARCH_ENDPOINT || ""; const client = new Client({ node: OPENSEARCH_ENDPOINT }); exports.handler = async (event) => { const result = await client.search({ index: 'devio_sample', pretty: true }); return result; }; /index.js 0QFO4FBSDIͷ +4༻ΫϥΠΞϯτΛར༻
  8. -BNCEBͷιʔείʔυྫʢ/PEFYʣ  const { Client } = require('@opensearch-project/opensearch'); const OPENSEARCH_ENDPOINT

    = process.env.OPENSEARCH_ENDPOINT || ""; const client = new Client({ node: OPENSEARCH_ENDPOINT }); exports.handler = async (event) => { const result = await client.search({ index: 'devio_sample', pretty: true }); return result; }; /index.js ؀ڥม਺ͰΤϯυϙΠϯτΛ ઃఆͰ͖ΔΑ͏ʹ͓ͯ͘͠