|
1 | 1 | [[mapping-field-names-field]]
|
2 | 2 | === `_field_names` field
|
3 | 3 |
|
4 |
| -The `_field_names` field indexes the names of every field in a document that |
5 |
| -contains any value other than `null`. This field is used by the |
| 4 | +The `_field_names` field used to index the names of every field in a document that |
| 5 | +contains any value other than `null`. This field was used by the |
6 | 6 | <<query-dsl-exists-query,`exists`>> query to find documents that
|
7 | 7 | either have or don't have any non-+null+ value for a particular field.
|
8 | 8 |
|
9 |
| -The value of the `_field_names` field is accessible in queries: |
10 |
| - |
11 |
| -[source,js] |
12 |
| --------------------------- |
13 |
| -# Example documents |
14 |
| -PUT my_index/_doc/1 |
15 |
| -{ |
16 |
| - "title": "This is a document" |
17 |
| -} |
18 |
| -
|
19 |
| -PUT my_index/_doc/2?refresh=true |
20 |
| -{ |
21 |
| - "title": "This is another document", |
22 |
| - "body": "This document has a body" |
23 |
| -} |
24 |
| -
|
25 |
| -GET my_index/_search |
26 |
| -{ |
27 |
| - "query": { |
28 |
| - "terms": { |
29 |
| - "_field_names": [ "title" ] <1> |
30 |
| - } |
31 |
| - } |
32 |
| -} |
33 |
| -
|
34 |
| --------------------------- |
35 |
| -// CONSOLE |
36 |
| - |
37 |
| -<1> Querying on the `_field_names` field (also see the <<query-dsl-exists-query,`exists`>> query) |
38 |
| - |
| 9 | +Now the `_field_names` field only indexes the names of fields that have |
| 10 | +`doc_values` and `norms` disabled. For fields which have either `doc_values` |
| 11 | +or `norm` enabled the <<query-dsl-exists-query,`exists`>> query will still |
| 12 | +be available but will not use the `_field_names` field. |
39 | 13 |
|
40 | 14 | ==== Disabling `_field_names`
|
41 | 15 |
|
42 |
| -Because `_field_names` introduce some index-time overhead, you might want to |
43 |
| -disable this field if you want to optimize for indexing speed and do not need |
44 |
| -`exists` queries. |
| 16 | +Disabling `_field_names` is often not necessary because it no longer |
| 17 | +carries the index overhead it once did. If you have a lot of fields |
| 18 | +which have `doc_values` and `norms` disabled and you do not need to |
| 19 | +execute `exists` queries using those fields you might want to disable |
| 20 | +`_field_names` be adding the following to the mappings: |
45 | 21 |
|
46 | 22 | [source,js]
|
47 | 23 | --------------------------------------------------
|
|
0 commit comments