mapping
PUT /movie
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "english"
},
"tagline": {
"type": "text",
"analyzer": "english"
},
"release_date": {
"type": "date",
"format": "8yyyy/mm/dd||yyyy/m/d||yyyy/mm/d||yyyy/m/dd"
},
"popularity": {
"type": "double"
},
"cast": {
"type": "object",
"properties": {
"character": {
"type": "text",
"analyzer": "standard"
},
"name": {
"type": "text",
"analyzer": "standard"
}
}
},
"overview": {
"type": "text",
"analyzer": "english"
}
}
}
}
得分调整
GET /movie/_search
{
"explain": true,
"query": {
"function_score": {
"query": {
"multi_match": {
"query": "steve job",
"fields": [
"title",
"overview"
],
"operator": "or",
"type": "most_fields"
}
},
"functions": [
{
"field_value_factor": {
"field": "popularity", //处理要调整的字段
"modifier": "log2p", // 处理的数学公式
"factor": 5
}
} ,
{
"field_value_factor": {
"field": "popularity", //处理要调整的字段
"modifier": "log2p",
"factor": 10
}
}
],
"score_mode": "sum" // 默认是相乘,不同的field_value之间的运算
, "boost_mode": "sum" // 与oldVlaue相加
}
}
}