# Help, make a selection by the field of the object

**URL:** <https://discuss.elastic.co/t/help-make-a-selection-by-the-field-of-the-object/342245>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-monitoring\
**Created:** [September 4, 2023, 10:27am UTC](https://discuss.elastic.co/t/help-make-a-selection-by-the-field-of-the-object/342245 "2023-09-04T10:27:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sitnik.ilya.93](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sitnik.ilya.93/32/125265_2.png) [@sitnik.ilya.93](https://discuss.elastic.co/u/sitnik.ilya.93)\
**Post date:** [September 4, 2023, 10:27am UTC](https://discuss.elastic.co/t/help-make-a-selection-by-the-field-of-the-object/342245/1 "2023-09-04T10:27:24Z")

</div>

you need to make a selection only by file type, the object was saved simply as Object.class  
try to choose by,

```auto
searchResponse = osClient.search(new SearchRequest(eventIndex)
                             .scroll(scroll)
                     .source(
                     newSearchSourceBuilder().query(
                             QueryBuilders.matchPhraseQuery("metaInfo.object.type",searchQuery.getObject())
                     )
             ), RequestOptions.DEFAULT);

```

we output is always 0

---

<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:** [October 2, 2023, 10:27am UTC](https://discuss.elastic.co/t/help-make-a-selection-by-the-field-of-the-object/342245/2 "2023-10-02T10:27:51Z")

</div>

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