Skip to content

Instantly share code, notes, and snippets.

@mcalavera81
Created January 9, 2022 11:21
Show Gist options
  • Save mcalavera81/57e05315af85cad0b6035e76802352d9 to your computer and use it in GitHub Desktop.
Save mcalavera81/57e05315af85cad0b6035e76802352d9 to your computer and use it in GitHub Desktop.
POST /tmdb/_close
POST /tmdb/_open
PUT /tmdb/_settings
{
"analysis": {
"filter": {
"my_shingle": {
"type": "shingle",
"min_shingle_size": 2,
"max_shingle_size": 4,
"output_unigrams": false
}
},
"analyzer": {
"my_shingler": {
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase", "shingle"]
}
}
}
}
GET /tmdb/_mapping
PUT /tmdb/_mapping
{
"properties": {
"overview" : {
"type": "text",
"fields" : {
"shingled" : {
"type" : "text",
"analyzer" : "my_shingler"
}
}
}
}
}
PUT /tmdb/_mapping
{
"properties": {
"title" : {
"type": "text",
"analyzer" : "english",
"fields" : {
"shingled" : {
"type" : "text",
"analyzer" : "my_shingler"
}
}
}
}
}
POST tmdb/_update_by_query?conflicts=proceed
GET /tmdb/_search
{
"query": {
"match": {
"title": "united stars"
}
},
"_source": ["title"]
}
POST tmdb/_search
{
"suggest": {
"job-suggest": {
"text": "tronco",
"phrase": {
"field": "title.shingled",
"direct_generator": [{"field": "title"}],
"smoothing": {
"stupid_backoff": {
"discount": 0.5
}
},
"confidence":1,
"max_errors": 3,
"highlight": {
"pre_tag": "<em>",
"post_tag": "</em>"
},
"collate": {
"prune": "true",
"query":{
"inline": {
"match_phrase": {
"{{field_name}}": {
"query": "{{suggestion}}"
}
}
}
},
"params": {
"field_name": "title"
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment