Socket
Book a DemoInstallSign in
Socket

github.com/xarick/golang-mongodb-elasticsearch-example

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/xarick/golang-mongodb-elasticsearch-example

Source
Go Modules
Version
v0.0.0-20250127060010-a2061b246463
Version published
Created
Source

golang-mongodb-elasticsearch-example

  • Running Docker Compose (docker-compose.yml is in the project)
docker-compose up -d
  • Connecting to the MongoDB server (2 different methods)
docker exec -it mongodb bash
docker exec -it mongodb mongosh -u admin -p admin123 --authenticationDatabase admin
  • Elasticsearchda indeksni qo'lda qo'shish uchun
curl -X PUT "http://localhost:9200/news" -H 'Content-Type: application/json' -d '{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0
  },
  "mappings": {
    "properties": {
      "title": { "type": "text" },
      "content": { "type": "text" },
      "author": { "type": "keyword" },
      "source": { "type": "keyword" },
      "published": { "type": "date" },
      "created_at": { "type": "date" }
    }
  }
}'
  • Elasticsearch buyruqlari
curl -X GET "http://localhost:9200/_cat/indices?v"          # Indekslar ro'yxatini ko'rish
curl -X GET "http://localhost:9200/news"                    # news indeksini ko'rish
curl -X GET "http://localhost:9200/news/_mapping?pretty"    # Maydon turlarini ko'rish
curl -X GET "http://localhost:9200/news/_count"             # new indeksida hujjat sonini ko'rish
  • news indeksida birinchi 10 ta hujjatni ko'rish
curl -X GET "http://localhost:9200/news/_search?pretty" -H 'Content-Type: application/json' -d '{
  "size": 10,
  "query": {
    "match_all": {}
  }
}'

FAQs

Package last updated on 27 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts