# Set DataHub filter predicate for c8y\_IsDevice

**URL:** <https://community.cumulocity.com/t/set-datahub-filter-predicate-for-c8y-isdevice/1305>\
**Category:** Forum\
**Tags:** cumulocity\
**Created:** [August 31, 2022, 12:36pm UTC](https://community.cumulocity.com/t/set-datahub-filter-predicate-for-c8y-isdevice/1305 "2022-08-31T12:36:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marco\_Biegel](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Marco\_Biegel](https://community.cumulocity.com/u/Marco_Biegel)\
**Post date:** [August 31, 2022, 12:36pm UTC](https://community.cumulocity.com/t/set-datahub-filter-predicate-for-c8y-isdevice/1305/1 "2022-08-31T12:36:21Z")

</div>

Hi,

I would like to offload just device inventory objects. So I tried to set the right filter predicate within the offloading job but do not succeed. Seems like DataHub puts either true or false in the exported column “c8y\_IsDevice” dependent on the existence of c8y\_IsDevice = {} in the MO.

So I tried following statements (and much more):

src.“c8y\_IsDevice” IS true does not work.

src.“c8y\_IsDevice” = true does not work.

src.“c8y\_IsDevice” IS NOT NULL works, but of course does not do the right thing, because Data Hub always puts a value in the column.

I also tried casting to boolean or string within the filter expression.  
Did anyone do this before? Filtering for not Boolean Columns seems to work as expected.

Thanks & Best Regards  
Marco

---

<div class="post-metadata">

**Author:** ![Marco\_Biegel](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Marco\_Biegel](https://community.cumulocity.com/u/Marco_Biegel)\
**Post date:** [August 31, 2022, 1:13pm UTC](https://community.cumulocity.com/t/set-datahub-filter-predicate-for-c8y-isdevice/1305/2 "2022-08-31T13:13:51Z")

</div>

We just got the answer from R&D - It´s not that obvious. The solution could look like this: On mongo level exists a “\_fragments” array, which contains all fragments of an inventory object. By seeking within the array for c8y\_IsDevice you can filter for it:

convert\_from(convert\_to(“\_fragments”, ‘JSON’), ‘UTF8’) LIKE ‘%“c8y\_IsDevice”%’

---

<div class="post-metadata">

**Author:** ![anon53547040](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@anon53547040](https://community.cumulocity.com/u/anon53547040)\
**Post date:** [September 5, 2022, 9:56am UTC](https://community.cumulocity.com/t/set-datahub-filter-predicate-for-c8y-isdevice/1305/3 "2022-09-05T09:56:04Z")

</div>

Hi Marco,

there is no better solution currently. Would you mind to create an idea in Aha!? I’d actually like to see an option on CDH’s UI (“Devices only” checkbox or so). The solution posted here now leaks the internal MongoDB data model – that’s not good style and it might break anytime (it won’t most likely, but it could…)

Thanks, Tim

---

<div class="post-metadata">

**Author:** ![Murat\_Bayram](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/murat_bayram/32/3670_2.png) [@Murat\_Bayram](https://community.cumulocity.com/u/Murat_Bayram)\
**Post date:** [September 5, 2022, 11:09am UTC](https://community.cumulocity.com/t/set-datahub-filter-predicate-for-c8y-isdevice/1305/4 "2022-09-05T11:09:50Z")

</div>

We first tried it via e.g. ‘c8y\_IsDevice is not NULL’ but that does somehow not work although it gives back the correct results within the Dremio UI.

We will create an idea about that. Additionally on top we would highly appreciate a more detailed “Best Practice” section within the [documentation](https://cumulocity.com/guides/datahub/working-with-datahub/#datahub-best-practices) where queries for all typical use cases are listed (e.g. measurements contains fragments, Alarm before timestamp, event of certain type, device inventory, device with certain firmware etc. pp.)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)\
**Post date:** [March 4, 2023, 11:10am UTC](https://community.cumulocity.com/t/set-datahub-filter-predicate-for-c8y-isdevice/1305/5 "2023-03-04T11:10:24Z")

</div>

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