5
5
++++
6
6
7
7
The `combined_fields` query supports searching multiple text fields as if their
8
- contents had been indexed into one combined field. It takes a term-centric
9
- view of the query : first it analyzes the query string into individual terms,
8
+ contents had been indexed into one combined field. The query takes a term-centric
9
+ view of the input string : first it analyzes the query string into individual terms,
10
10
then looks for each term in any of the fields. This query is particularly
11
11
useful when a match could span multiple text fields, for example the `title`,
12
- `abstract` and `body` of an article:
12
+ `abstract`, and `body` of an article:
13
13
14
14
[source,console]
15
- --------------------------------------------------
15
+ ----
16
16
GET /_search
17
17
{
18
18
"query": {
@@ -23,31 +23,36 @@ GET /_search
23
23
}
24
24
}
25
25
}
26
- --------------------------------------------------
26
+ ----
27
27
28
28
The `combined_fields` query takes a principled approach to scoring based on the
29
29
simple BM25F formula described in
30
30
http://www.staff.city.ac.uk/~sb317/papers/foundations_bm25_review.pdf[The Probabilistic Relevance Framework: BM25 and Beyond].
31
31
When scoring matches, the query combines term and collection statistics across
32
- fields. This allows it to score each match as if the specified fields had been
33
- indexed into a single combined field. (Note that this is a best attempt --
34
- `combined_fields` makes some approximations and scores will not obey this
35
- model perfectly.)
32
+ fields to score each match as if the specified fields had been indexed into a
33
+ single, combined field. This scoring is a best attempt; `combined_fields` makes
34
+ some approximations and scores will not obey the BM25F model perfectly.
36
35
36
+ // tag::max-clause-limit[]
37
37
[WARNING]
38
38
.Field number limit
39
39
===================================================
40
- There is a limit on the number of fields that can be queried at once. It is
41
- defined by the `indices.query.bool.max_clause_count` <<search-settings>>
42
- which defaults to 1024.
40
+ By default, there is a limit to the number of clauses a query can contain. This
41
+ limit is defined by the
42
+ <<indices-query-bool-max-clause-count,`indices.query.bool.max_clause_count`>>
43
+ setting, which defaults to `1024`. For `combined_fields` queries, the number of
44
+ clauses is calculated as the number of fields multiplied by the number of terms.
43
45
===================================================
46
+ // end::max-clause-limit[]
44
47
45
48
==== Per-field boosting
46
49
47
- Individual fields can be boosted with the caret (`^`) notation:
50
+ Field boosts are interpreted according to the combined field model. For example,
51
+ if the `title` field has a boost of 2, the score is calculated as if each term
52
+ in the title appeared twice in the synthetic combined field.
48
53
49
54
[source,console]
50
- --------------------------------------------------
55
+ ----
51
56
GET /_search
52
57
{
53
58
"query": {
@@ -57,11 +62,8 @@ GET /_search
57
62
}
58
63
}
59
64
}
60
- --------------------------------------------------
61
-
62
- Field boosts are interpreted according to the combined field model. For example,
63
- if the `title` field has a boost of 2, the score is calculated as if each term
64
- in the title appeared twice in the synthetic combined field.
65
+ ----
66
+ <1> Individual fields can be boosted with the caret (`^`) notation.
65
67
66
68
NOTE: The `combined_fields` query requires that field boosts are greater than
67
69
or equal to 1.0. Field boosts are allowed to be fractional.
@@ -149,7 +151,7 @@ term-centric: `operator` and `minimum_should_match` are applied per-term,
149
151
instead of per-field. Concretely, a query like
150
152
151
153
[source,console]
152
- --------------------------------------------------
154
+ ----
153
155
GET /_search
154
156
{
155
157
"query": {
@@ -160,12 +162,15 @@ GET /_search
160
162
}
161
163
}
162
164
}
163
- --------------------------------------------------
165
+ ----
164
166
165
- is executed as
167
+ is executed as:
166
168
167
- +(combined("database", fields:["title" "abstract"]))
168
- +(combined("systems", fields:["title", "abstract"]))
169
+ [source,txt]
170
+ ----
171
+ +(combined("database", fields:["title" "abstract"]))
172
+ +(combined("systems", fields:["title", "abstract"]))
173
+ ----
169
174
170
175
In other words, each term must be present in at least one field for a
171
176
document to match.
@@ -178,8 +183,8 @@ to scoring based on the BM25F algorithm.
178
183
[NOTE]
179
184
.Custom similarities
180
185
===================================================
181
- The `combined_fields` query currently only supports the ` BM25` similarity
182
- ( which is the default unless a <<index-modules-similarity, custom similarity>>
183
- is configured) . <<similarity, Per-field similarities>> are also not allowed.
186
+ The `combined_fields` query currently only supports the BM25 similarity,
187
+ which is the default unless a <<index-modules-similarity, custom similarity>>
188
+ is configured. <<similarity, Per-field similarities>> are also not allowed.
184
189
Using `combined_fields` in either of these cases will result in an error.
185
190
===================================================
0 commit comments