# Question about create data view API

**URL:** <https://discuss.elastic.co/t/question-about-create-data-view-api/308530>\
**Category:** Kibana\
**Created:** [June 30, 2022, 2:39am UTC](https://discuss.elastic.co/t/question-about-create-data-view-api/308530 "2022-06-30T02:39:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![busishe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/busishe/32/107755_2.png) [@busishe](https://discuss.elastic.co/u/busishe)\
**Post date:** [June 30, 2022, 2:39am UTC](https://discuss.elastic.co/t/question-about-create-data-view-api/308530/1 "2022-06-30T02:39:20Z")

</div>

> **[Create data view API | Kibana Guide \[8.3\] | Elastic](https://www.elastic.co/guide/en/kibana/current/data-views-api-create.html)**
>
> Conceptual and step-by-step procedures for using runtime fields, scripted fields, and field formatters.

i want to create a dataview with only "message" field,how can i make the post request?  
the example only show "fields" is an object,but didnt tell the detail properties in the object.

$ curl -X POST api/data\_views/data\_view  
{  
"data\_view": {  
"id": "...",  
"version": "...",  
"title": "...",  
"type": "...",  
"timeFieldName": "...",  
"sourceFilters": ,  
"fields": {},  
"typeMeta": {},  
"fieldFormats": {},  
"fieldAttrs": {},  
"runtimeFieldMap": {}  
"allowNoIndex": "..."  
}  
}

---

<div class="post-metadata">

**Author:** ![JLeysens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jleysens/32/67404_2.png) [@JLeysens](https://discuss.elastic.co/u/JLeysens)\
**Post date:** [July 4, 2022, 10:32am UTC](https://discuss.elastic.co/t/question-about-create-data-view-api/308530/2 "2022-07-04T10:32:20Z")

</div>

Hello! Hm, that documentation does seem to be incomplete.

I've opened an issue for tracking: [[Data views] Documentation for create data view endpoint incomplete · Issue #135522 · elastic/kibana · GitHub](https://github.com/elastic/kibana/issues/135522)

It looks like the expected shape of the `sourceFilters` field is:

```auto
...
  // Used by discover to hide fields.
  sourceFilters: [{value: "value"}]
...

```

I'm not certain this is going to do what you expect it should. Usually data views capture the full set of fields. You might be able to do this with field level security:

> **[Field level security | Elasticsearch Guide \[8.3\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/field-level-security.html)**

---

<div class="post-metadata">

**Author:** ![mattkime](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattkime/32/43522_2.png) [@mattkime](https://discuss.elastic.co/u/mattkime)\
**Post date:** [July 4, 2022, 8:51pm UTC](https://discuss.elastic.co/t/question-about-create-data-view-api/308530/3 "2022-07-04T20:51:25Z")

</div>

`sourceFilters` is only used by discover. I believe field level security is the only option.

---

<div class="post-metadata">

**Author:** ![busishe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/busishe/32/107755_2.png) [@busishe](https://discuss.elastic.co/u/busishe)\
**Post date:** [July 5, 2022, 1:19am UTC](https://discuss.elastic.co/t/question-about-create-data-view-api/308530/4 "2022-07-05T01:19:59Z")

</div>

thx for answer!i'm sorry i put the wrong checkbox on key "sourcefilter" by mistake and this make some misleading.My question is how to drop unnecessary fields when i create a dataview.Finally i achieved by edit filebeat.yml config.And the object "field" inner details will returned after i called kibana api "create dataview".

---

<div class="post-metadata">

**Author:** ![busishe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/busishe/32/107755_2.png) [@busishe](https://discuss.elastic.co/u/busishe)\
**Post date:** [July 5, 2022, 1:20am UTC](https://discuss.elastic.co/t/question-about-create-data-view-api/308530/5 "2022-07-05T01:20:32Z")

</div>

thx for answer!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 2, 2022, 1:21am UTC](https://discuss.elastic.co/t/question-about-create-data-view-api/308530/6 "2022-08-02T01:21:27Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
