mapping

  1. PUT /movie
  2. {
  3. "settings": {
  4. "number_of_shards": 3,
  5. "number_of_replicas": 1
  6. },
  7. "mappings": {
  8. "properties": {
  9. "title": {
  10. "type": "text",
  11. "analyzer": "english"
  12. },
  13. "tagline": {
  14. "type": "text",
  15. "analyzer": "english"
  16. },
  17. "release_date": {
  18. "type": "date",
  19. "format": "8yyyy/mm/dd||yyyy/m/d||yyyy/mm/d||yyyy/m/dd"
  20. },
  21. "popularity": {
  22. "type": "double"
  23. },
  24. "cast": {
  25. "type": "object",
  26. "properties": {
  27. "character": {
  28. "type": "text",
  29. "analyzer": "standard"
  30. },
  31. "name": {
  32. "type": "text",
  33. "analyzer": "standard"
  34. }
  35. }
  36. },
  37. "overview": {
  38. "type": "text",
  39. "analyzer": "english"
  40. }
  41. }
  42. }
  43. }

得分调整

  1. GET /movie/_search
  2. {
  3. "explain": true,
  4. "query": {
  5. "function_score": {
  6. "query": {
  7. "multi_match": {
  8. "query": "steve job",
  9. "fields": [
  10. "title",
  11. "overview"
  12. ],
  13. "operator": "or",
  14. "type": "most_fields"
  15. }
  16. },
  17. "functions": [
  18. {
  19. "field_value_factor": {
  20. "field": "popularity", //处理要调整的字段
  21. "modifier": "log2p", // 处理的数学公式
  22. "factor": 5
  23. }
  24. } ,
  25. {
  26. "field_value_factor": {
  27. "field": "popularity", //处理要调整的字段
  28. "modifier": "log2p",
  29. "factor": 10
  30. }
  31. }
  32. ],
  33. "score_mode": "sum" // 默认是相乘,不同的field_value之间的运算
  34. , "boost_mode": "sum" // oldVlaue相加
  35. }
  36. }
  37. }