This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET index_1/_search | |
{ | |
"query": { | |
"match_all": {} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET index_1/_search | |
{ | |
"size": 20, | |
"query": { | |
"match_all": {} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET books_from_amazon/_search | |
{ | |
"size": 20, | |
"query": { | |
"match_all": {} | |
}, | |
"sort": [ | |
{ | |
"name.keyword": { | |
"order": "desc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import the library | |
const eb = require('elastic-builder'); // the builder | |
// create the 'body' and add 'query' contents / conditions | |
const requestBody = new eb.RequestBodySearch() | |
.query(new eb.MatchQuery('product_desc', 'sports shoes yellow shoe laces')); | |
// get back the build json | |
//{ | |
// "query": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// connect to a node (localhost:9200) | |
var client = new $.es.Client({ | |
hosts: 'localhost:9200' | |
}); | |
// run a simple query | |
client.search({ | |
index: 'product_index', | |
type: 'doc', | |
body: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import the 'elasticsearch' package / library | |
var elasticsearch = require('elasticsearch'); | |
// connect to a node (localhost:9200 | |
var client = new elasticsearch.Client({ | |
host: 'localhost:9200' | |
}); | |
// run a query | |
client.search({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PUT imdb_nested | |
{ | |
"mappings": { | |
"properties": { | |
"actors": { | |
"type": "nested", | |
"properties": { | |
"id": { | |
"type": "keyword" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST imdb_nested/_bulk | |
{"index":{"_id":"re_1"}} | |
{"movie":{"year":2002,"img":"https://m.media-amazon.com/images/M/MV5BZmI1ZGRhNDYtOGVjZC00MmUyLThlNTktMTQyZGE3MzE1ZTdlXkEyXkFqcGdeQXVyNDE5MTU2MDE@._V1_UY268_CR1,0,182,268_AL_.jpg","name":"Resident Evil (2002)","duration":{"display":"1h 40min","in_min":100},"genre":["action","horror","sci-fi"],"genre_display":"action, horror, sci-fi","stars":6.7,"desc":"A special military unit fights a powerful, out-of-control supercomputer and hundreds of scientists who have mutated into flesh-eating creatures after a laboratory accident","director":"Paul W.S. Anderson"},"actors":[{"id":"act_001","name":"Milla Jovovich","avatar":"https://m.media-amazon.com/images/M/MV5BNzA1Nzc4NjYwNV5BMl5BanBnXkFtZTcwNjA2NjY1Mg@@._V1_UY317_CR18,0,214,317_AL_.jpg","home":"https://www.imdb.com/name/nm0000170/?ref_=tt_ov_st_sm"},{"id":"act_003","name":"Michelle Rodriguez","avatar":"https://m.media-amazon.com/images/M/MV5BYThkMmY1OTYtMTZmNi00YTVmLThkMGItNDlhNzE0ZDZkNGQ0XkEyXkFqcGdeQXVyMjQwMDg0Ng@@._V |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST _ingest/pipeline/_simulate | |
{ | |
"pipeline": { | |
"description": "PRE-PROCESSING: add back last_update_time by using the ingest object", | |
"processors": [ | |
{ | |
"set": { | |
"field": "last_update_time", | |
"value": "{{_ingest.timestamp}}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST _ingest/pipeline/_simulate | |
{ | |
"pipeline": { | |
"description": "any stage: add back last_update_time by script", | |
"processors": [ | |
{ | |
"script": { | |
"lang": "painless", | |
"source": """ | |
def ts = new Date(); |
OlderNewer