Cercare il testo intero (Pt 2 SSK2 Introduzione a OpenSearch) (Italiano (Italian))

Cercare il testo intero (Pt 2 SSK2 Introduzione a OpenSearch)

Saturday, 24 August 2024

//

5 minute read

Introduzione

Nelle parti precedenti di questa serie abbiamo introdotto il concetto della ricerca completa del testo e come può essere usata per cercare il testo in una base di dati. In questa parte introduceremo OpenSearch, un potente motore di ricerca che può essere usato per ricercare il testoM SK2

In questa parte vi spiegheremo come far funzionare OpenSearch.

Elementi precedenti in questa serie:

Successive parti della serie:

Cos'è OpenSearch?

OpenSearch è un motore di ricerca progettato per essere veloce, scalabile e facile da usare. E' una parte di Elasticsearch , un populare motore che viene usato da molte aziende per far funzionare la loro funzione di ricercaM SK3 OpenSearch è progettata per essere facile da utilizzare e può essere usata per cercare il testo in diversi modi

Tuttavia, non è un animale semplice da usare e quindi copreremo le basi di questo articolo.

Opensearch

L'installazione di OpenSearch

Primo, questo non è' non è una configurazione che dovreste usare nella produzione ; configura un certo numero di utenti demo e password che non sono sicure. Documentazione ufficiale per creare un cluster sicuro.

In primo luogo, usiamo la configurazione predefinita M SK1Development' installazione di docker dell'Opensearch & Opensearch Dashboards

Guardate qui per tutti i dettagli sul La configurazione del docker compose.

Dovreste fare una piccola modifica a wsl o / il vostro host linux per farla funzionare flessivamente. Configurazioni per Linux Per un ambiente Linux, fate partire le following commands:

Disable memory paging and swapping performance on the host to improve performance.

sudo swapoff -a

Aumentare il numero di mappe di memoria disponibili per OpenSearch.


# Edit the sysctl config file
sudo vi /etc/sysctl.conf

# Add a line to define the desired value
# or change the value if the key exists,
# and then save your changes.
vm.max_map_count=262144

# Reload the kernel parameters using sysctl
sudo sysctl -p

# Verify that the change was applied by checking the value
cat /proc/sys/vm/max_map_count

Configurazioni per Windows Per i carichi di lavoro per Windows che usano WSL attraverso il Docker Desktop, fate partire le following commands in un terminale per stabilire vmM SK1max_map _countMSC4

wsl -d docker-desktop
sysctl -w vm.max_map_count=262144

Poi si può creare un .env file nello stesso directorio del vostro computer. docker-compose.yml file con il contenuto seguente: bash OPENSEARCH_INITIAL_ADMIN_PASSWORD=<somepasswordwithlowercaseuppercaseandspecialchars>

Ora usate il following docker-compose file to set up the cluster:

version: '3'
services:
  opensearch-node1: # This is also the hostname of the container within the Docker network (i.e. https://opensearch-node1/)
    image: opensearchproject/opensearch:latest # Specifying the latest available image - modify if you want a specific version
    container_name: opensearch-node1
    environment:
      - cluster.name=opensearch-cluster # Name the cluster
      - node.name=opensearch-node1 # Name the node that will run in this container
      - discovery.seed_hosts=opensearch-node1,opensearch-node2 # Nodes to look for when discovering the cluster
      - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 # Nodes eligible to serve as cluster manager
      - bootstrap.memory_lock=true # Disable JVM heap memory swapping
      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
      - OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_INITIAL_ADMIN_PASSWORD}    # Sets the demo admin user password when using demo configuration, required for OpenSearch 2.12 and later
    ulimits:
      memlock:
        soft: -1 # Set memlock to unlimited (no soft or hard limit)
        hard: -1
      nofile:
        soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
        hard: 65536
    volumes:
      - opensearch-data1:/usr/share/opensearch/data # Creates volume called opensearch-data1 and mounts it to the container
    ports:
      - 9200:9200 # REST API
      - 9600:9600 # Performance Analyzer
    networks:
      - opensearch-net # All of the containers will join the same Docker bridge network
  opensearch-node2:
    image: opensearchproject/opensearch:latest # This should be the same image used for opensearch-node1 to avoid issues
    container_name: opensearch-node2
    environment:
      - cluster.name=opensearch-cluster
      - node.name=opensearch-node2
      - discovery.seed_hosts=opensearch-node1,opensearch-node2
      - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2
      - bootstrap.memory_lock=true
      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
      - OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_INITIAL_ADMIN_PASSWORD}
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    volumes:
      - opensearch-data2:/usr/share/opensearch/data
    networks:
      - opensearch-net
  opensearch-dashboards:
    image: opensearchproject/opensearch-dashboards:latest # Make sure the version of opensearch-dashboards matches the version of opensearch installed on other nodes
    container_name: opensearch-dashboards
    ports:
      - 5601:5601 # Map host port 5601 to container port 5601
    expose:
      - "5601" # Expose port 5601 for web access to OpenSearch Dashboards
    environment:
      OPENSEARCH_HOSTS: '["https://opensearch-node1:9200","https://opensearch-node2:9200"]' # Define the OpenSearch nodes that OpenSearch Dashboards will query
    networks:
      - opensearch-net

volumes:
  opensearch-data1:
  opensearch-data2:

networks:
  opensearch-net:

Questo docker-compose file creerà un gruppo di nodi 2 dell'Opensearch e un singolo node delle tavole da scatola OpensearchM SK2

Si basa sul vostro file .env per stabilire il OPENSEARCH_INITIAL_ADMIN_PASSWORD variabile.

Poi spingetelo su.

docker compose -f opensearch-docker.yml up -d

In futuro ' approfondiremo cosa sta facendo e come la configurare per la produzione .

Accedere a OpenSearch

Una volta che il cluster è in funzione, si può accedere all'interfaccia OpenSearch Dashboards navigando su http://localhost:5601 nel vostro navigatore web. Si può registrare usando il nome di usuario. admin e la password che avete messo nel .env file.

Opensearch Dashboards

Questa è l'interfaccia principale dell'amministratore (la potete riempire con qualche campione di dati e giocarci con.

Opensearch Dashboards

Conclusione

Nella prossima parte I' vi spiegherò come portare i dati in opensearch e chiederli.

Finding related posts...
logo

© 2026 Scott Galloway — Unlicense — All content and source code on this site is free to use, copy, modify, and sell.