Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
POST /test/product/_search
{
"query": {
"function_score": {
"query": { "match": { "name" : "การ์ดแสดงผล"} },
"functions": [
{
"filter": { "match": { "name": "ASUS" } },
"weight": 3
},
{
"filter": { "match": { "name": "MSI" } },
"weight": 5
}
]
}
}
}
PUT test
{
"settings": {
"analysis": {
"analyzer": {
"trigrams": {
"tokenizer": "trigram_tokenizer",
"filter": [
"lowercase"
]
}
},
"tokenizer": {
"trigram_tokenizer": {
"type": "ngram",
"min_gram": 3,
"max_gram": 3,
"token_chars": []
}
}
}
},
"mappings": {
"product": {
"properties": {
"name": {
"type": "text",
"analyzer": "trigrams"
},
"cost" :{
"type": "integer"
}
}
}
}
}
POST _bulk
{ "index" : { "_index" : "test", "_type" : "product", "_id" : "1" } }
{"name" : "VGA (การ์ดแสดงผล) ASUS CERBERUS GTX1070TI A8G", "cost":2300}
{ "index" : { "_index" : "test", "_type" : "product", "_id" : "2" } }
{"name" : "VGA (การ์ดแสดงผล) INNO3D GTX 1070 Ti X2 V2 8GB ( N107T-2SDN-P5DS )", "cost":2500}
{ "index" : { "_index" : "test", "_type" : "product", "_id" : "3" } }
{"name" : "VGA (การ์ดแสดงผล) MSI GTX 1080 Ti ARMOR 11G OC", "cost":2700}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment