Skip to content

nikbarseghyan/mongo-tranfer-elastic

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Installation and Running

$ npm install
$ npm run start
##
# Run docker-compose
$docker-compose up -d
##

ElasticSearch Query

##
# Check Index.
##
$curl -X GET http://192.168.171.141:9200/_aliases?pretty=true
##
# Get Data.
$curl -X GET http://localhost:9200/_search
##
# Delet all Indexes.
$curl -X DELETE 'localhost:9200/_all'
##
##

Request (Create Product in MongoDB and Create Index in Elastic)

##
# Postman POST Request.
http://localhost:3022/api/v1/products
##
# Request Body
{
    "name": "Iphone 13",      # Indexed
    "price": 999,
    "isComplet": true,
    "llc": "Apple LLC"        # Indexed
}
##
# Postman POST Request.
http://localhost:3022/api/v1/elastic/search?q=PC/name/33
##
##

Query description

########################################################################################################
#         |    Search Data      |               Elastic indexes                    | Pagination
#         |                     |                                                  |
# ?query= |    JavaScript       |    /  name   /   llc    /  ...  /  ...           |/ 22
#         |                     |                                                  |
#         | Should be the first |            Search fields                         | Should be the last
########################################################################################################
# Search for target data.
##
$ http://localhost:3022/api/v1/elastic/search?q={ SEARCH_STRING }
##
$ http://localhost:3022/api/v1/elastic/search?q={ SEARCH_STRING_1 SEARCH_STRING_2 }/{  SEARCH_FIELDS_1, ...}/{ 22 }
##
# Example.
$ http://localhost:3022/api/v1/elastic/search?q=JavaScript/title/tags/authors/12
##