Skip to content

Commit

Permalink
Update ignored.md
Browse files Browse the repository at this point in the history
Signed-off-by: Melissa Vagi <[email protected]>

Signed-off-by: Melissa Vagi <[email protected]>
  • Loading branch information
vagimeli authored Jul 17, 2024
1 parent 47a1bf9 commit 00fc9c1
Showing 1 changed file with 82 additions and 3 deletions.
85 changes: 82 additions & 3 deletions _field-types/metadata-fields/ignored.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You can query the `_ignored` field using `term`, `terms`, and `exists` queries,
The `_ignored` field is only populated when the `ignore_malformed` setting is enabled in your index mapping. If `ignore_malformed` is set to `false` (the default value), malformed fields will cause the entire document to be rejected, and the `_ignored` field will not be populated.
{: .note}

For example, the following query will retrieve all documents that have at least one field that was ignored during indexing:
The basic syntax for a request with `_ignored` is as follows:

```json
GET _search
Expand All @@ -31,7 +31,86 @@ GET _search
```
{% include copy-curl.html %}

Similarly, you can use a term query to find documents where a specific field, such as created_at, was ignored:
---

#### Example indexing request with `_ignored` field

The following example request adds a new document to the `test-ignored` index, with `ignore_malformed` set to `true` so that no error is thrown during indexing:

```json
PUT test-ignored
{
"mappings": {
"properties": {
"title": {
"type": "text"
},
"length": {
"type": "long",
"ignore_malformed": true
}
}
}
}

POST test-ignored/_doc
{
"title": "correct text",
"length": "not a number"
}

GET test-ignored/_search
{
"query": {
"exists": {
"field": "_ignored"
}
}
}
```
{% include copy-curl.html %}

#### Example reponse

```json
{
"took": 42,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "test-ignored",
"_id": "qcf0wZABpEYH7Rw9OT7F",
"_score": 1,
"_ignored": [
"length"
],
"_source": {
"title": "correct text",
"length": "not a number"
}
}
]
}
}
```

---

## Ignoring a specified field

Similarly, you can use a term query to find documents where a specific field, such as created_at, was ignored, as shown in the following example request:

```json
GET _search
Expand Down Expand Up @@ -66,4 +145,4 @@ GET _search
"hits": []
}
}
```
```

0 comments on commit 00fc9c1

Please sign in to comment.