Skip to content

Instantly share code, notes, and snippets.

@colepacak
Created April 15, 2020 15:06
Show Gist options
  • Save colepacak/583e8d2c0491387e602931a47844c1ce to your computer and use it in GitHub Desktop.
Save colepacak/583e8d2c0491387e602931a47844c1ce to your computer and use it in GitHub Desktop.
curl -X PUT "localhost:9200/suggestions?pretty" -H 'Content-Type: application/json' -d'
{
"mappings": {
"properties": {
"id": {
"type": "integer"
},
"type": {
"type": "keyword"
},
"suggestion": {
"type": "keyword"
}
}
}
}
'
# all quiet on the western front
curl -X POST "localhost:9200/suggestions/_doc" -H 'Content-Type: application/json' -d'
{
"id": 777,
"type": "snippet",
"suggestion": "all quiet on"
}
'
curl -X POST "localhost:9200/suggestions/_doc" -H 'Content-Type: application/json' -d'
{
"id": 777,
"type": "snippet",
"suggestion": "quiet on the"
}
'
curl -X POST "localhost:9200/suggestions/_doc" -H 'Content-Type: application/json' -d'
{
"id": 777,
"type": "snippet",
"suggestion": "on the western"
}
'
curl -X POST "localhost:9200/suggestions/_doc" -H 'Content-Type: application/json' -d'
{
"id": 777,
"type": "snippet",
"suggestion": "the western front"
}
'
curl -X POST "localhost:9200/suggestions/_doc" -H 'Content-Type: application/json' -d'
{
"id": 777,
"type": "snippet",
"suggestion": "western front"
}
'
curl -X POST "localhost:9200/suggestions/_doc" -H 'Content-Type: application/json' -d'
{
"id": 777,
"type": "snippet",
"suggestion": "front"
}
'
# quiet games are no fun
curl -X POST "localhost:9200/suggestions/_doc" -H 'Content-Type: application/json' -d'
{
"id": 666,
"type": "snippet",
"suggestion": "quiet games are"
}
'
curl -X POST "localhost:9200/suggestions/_doc" -H 'Content-Type: application/json' -d'
{
"id": 666,
"type": "snippet",
"suggestion": "games are no"
}
'
curl -X POST "localhost:9200/suggestions/_doc" -H 'Content-Type: application/json' -d'
{
"id": 666,
"type": "snippet",
"suggestion": "are no fun"
}
'
curl -X POST "localhost:9200/suggestions/_doc" -H 'Content-Type: application/json' -d'
{
"id": 666,
"type": "snippet",
"suggestion": "no fun"
}
'
curl -X POST "localhost:9200/suggestions/_doc" -H 'Content-Type: application/json' -d'
{
"id": 666,
"type": "snippet",
"suggestion": "fun"
}
'
curl http://localhost:9200/suggestions/_search?pretty -H "Content-Type: application/json" -d '{"query":{"match_all": {}}}'
curl -X GET "localhost:9200/suggestions/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"bool": {
"must": [
{
"prefix": {
"suggestion": {
"value": "quiet"
}
}
}
]
}
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment