提高字段的權重
GET /_search
{
"query": {
"multi_match": {
"query": "this is a test",
"fields": ["subject^3", "message"]
}
}
}
GET /_search
{
"query": {
"multi_match": {
"query": "this is a test",
"type": "most_fields",
"fields": ["subject^3", "message"]
}
}
}
// 等價於
GET /_search
{
"query": {
"bool": {
"should": [
{
"match": { "subject": { "query": "this is a test", "boost": 3 }}
},
{
"macth": { "message": "this is a test" }
}
]
}
}
}
GET /_search
{
"query": {
"query_string": {
"fields": ["content", "name^5"],
"query": "this AND that OR thus"
}
}
}
GET /_search
{
"query": {
"simple_query_string": {
"query": """"fried eggs" +(eggplant | potato) -frittata""",
"fields": ["title^5", "body"],
"default_operator": "and"
}
}
}
提高子句的權重
GET /_search
{
"query": {
"bool": {
"should": [
{
"match": { "subject": { "query": "this is a test", "boost": 3 }}
},
{
"macth": { "message": "this is a test" }
}
]
}
}
}
提高索引的權重
GET /_search
{
"indices_boost" : [
{ "alias1" : 1.4 },
{ "index*" : 1.3 }
]
}
本文出自
qbit snap