三种场景:
- 最佳字段(Best Fields)
当字段之间互相竞争,又互相关联。例如title和body这样的字段。评分来自最匹配字段GET accounts/_search{"query": {"multi_match": {"type": "best_fields","query": "strong","fields": ["firstname","lastname","email"],"tie_breaker": 0.2,"minimum_should_match": "20%" } }}
- 多数字段(Most Fields)
处理英文内容时:一种常见的手段是,在主字段(English Analyzer),抽取词干,加入同义词,以匹配更多的文档。相同的文本,加入子字段(Standard Analyzer),以提供更加精确的匹配。其他计算作为匹配文档提高相关度的信号。匹配字段越多越好。PUT titles{"mappings": {"properties": {"title": {"type": "text","analyzer": "english","fields": {"std": {"type":"text", "analyzer": "standard" } } } } }}GET titles/_search{"query": {"multi_match": {"type": "most_fields","query": "my boy","fields": ["title","title.std"] } }}
- 混合字段(Cross Field)
对于某些实体,例如人名、地址、图书信息。需要在多个字段中确定信息,单个字段只能作为整体的一部分。希望在任何这些列出的字段中找到尽可能多的词POST address/_search{"query": {"multi_match": {"query": "Poland W1V","type": "cross_fields","operator": "and","fields": ["street","city","country","postcode"] } }}
