2-3-05. multi_match Query
The multi_match query provides a convenient shorthand way of running the same query against multiple fields.
multi_match query는, 여러 field에 동일한 query를 실행하는, 아주 편리한 query이다.
There are several types of multi_match query, three of which just happen to coincide with the three scenarios that we listed in Know Your Data: best_fields, most_fields, and cross_fields.
multi_match query는 여러 가지 형태가 있다. Know Your Data에서 나열한 세가지 시나리오와 일치하는, 3가지(best fields, most fields, cross fields)이다.
By default, this query runs as type best_fields, which means that it generates a match query for each field and wraps them in a dis_max query. This dis_max query
기본적으로, multi_match query는 best field 형태로 실행한다. 즉, 각 field에 대해 match query를 생성하고, 그것을 dis_max query로 감싼다. 이 dis_max query는
{ "dis_max": { "queries": [ { "match": { "title": { "query": "Quick brown fox", "minimum_should_match": "30%" } } }, { "match": { "body": { "query": "Quick brown fox", "minimum_should_match": "30%" } } }, ], "tie_breaker": 0.3 } }
could be rewritten more concisely with multi_match as follows:
아래처럼, multi_match query로 요약해서 다시 작성될 수 있다.
{ "multi_match": { "query": "Quick brown fox", "type": "best_fields","fields": [ "title", "body" ], "tie_breaker": 0.3, "minimum_should_match": "30%"
} }
Using Wildcards in Field Namesedit
Field names can be specified with wildcards: any field that matches the wildcard pattern will be included in the search. You could match on the book_title, chapter_title, and section_titlefields, with the following:
field 이름은 wildcard로 지정될 수 있다. wildcard pattern에 일치하는, 모든 field는 검색에 포함된다. book_title, chapter_title, section_title 을 다음과 같이 일치시킬 수 있다.
{ "multi_match": { "query": "Quick brown fox", "fields": "*_title" } }
Boosting Individual Fieldsedit
Individual fields can be boosted by using the caret (^) syntax: just add ^boost after the field name, where boost is a floating-point number:
개별 field에, caret(^)을 사용해, 가중치를 부여할 수 있다. field 이름 뒤에 ^boost 를 추가하면 된다. boost 는 부동 소수점 숫자이다.