03. SelectInsertUpdateDelete en Solr 7.5

03.- Select,Insert,Update,Delete en Solr 7.5 ☀️

03. %2BSelect%252CInsert%252CUpdate%252CDelete%2Ben%2BSolr%2B7.5

1.- Instalar CURL

Debemos tener curl para comprobar si esta instalado ejecutamos

curl --version

Output

curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.1.0g zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3
Release-Date: 2018-01-24
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL

En caso de no tenerlo instalado debemos ejecutar estos comandos:

sudo apt-get update
sudo apt-get install curl

2.- Agregar un documentos (insert)

curl -X POST -H 'Content-Type: application/json' 'http://localhost:8983/solr/mycol1/update?commit=true' --data-binary '
{"add":
 {"doc":
  {"name":"eugenio","age":30}
 }
}'

3.- Actualizar un documento (update)

curl -X POST -H 'Content-Type: application/json' 'http://localhost:8983/solr/mycol1/update?commit=true' --data-binary '
[
 {"id":"c751f7a9-e725-4f61-97b7-c5ecd0355989", "name":"Eugenio","age":32 }
]'

4.- Borrar un documento (delete)

curl -X POST -H 'Content-Type: application/json' 'http://localhost:8983/solr/mycol1/update?commit=true' --data-binary '
{"delete": 
 {"id":"19ecb57d-56c1-4cbd-bc0c-ff4fa41a1b7e"}
}'

5.- Leer (Select)

curl -X POST -H 'Content-Type: application/json' 'http://localhost:8983/solr/mycol1/select?q=name:Eugenio2'

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *