# Missing predicate is missing

**URL:** <https://discourse.hibernate.org/t/missing-predicate-is-missing/4739>\
**Category:** Hibernate Search\
**Created:** [November 8, 2020, 8:03pm UTC](https://discourse.hibernate.org/t/missing-predicate-is-missing/4739 "2020-11-08T20:03:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xpete](https://avatars.discourse-cdn.com/v4/letter/x/bbce88/32.png) [@xpete](https://discourse.hibernate.org/u/xpete)\
**Post date:** [November 8, 2020, 8:03pm UTC](https://discourse.hibernate.org/t/missing-predicate-is-missing/4739/1 "2020-11-08T20:03:23Z")

</div>

I’am trying to filter some content based on whatever is has some defined Id or none.  
Something like this:

b.should(f.match().field(“groups.topic.id”).matching(topicId));  
b.should(f.missing().field(“groups”));  
b.minimumShouldMatchNumber(1);

I’ve seen on [HSEARCH-2464](https://hibernate.atlassian.net/browse/HSEARCH-2464) that the “missing” predicate is suposed to be implemented but it’s not and the @IndexedEmbedded.indexNullAs was removed as well. There’s any other way I can achieve what I Ineed? When the “missing” predicate is going to be implemented?

I’m using hibernate-search 6.0.0beta10  
Thanks

---

<div class="post-metadata">

**Author:** ![yrodiere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/yrodiere/32/1760_2.png) [@yrodiere](https://discourse.hibernate.org/u/yrodiere)\
**Post date:** [November 9, 2020, 7:22am UTC](https://discourse.hibernate.org/t/missing-predicate-is-missing/4739/2 "2020-11-09T07:22:35Z")

</div>

As explained [here](https://docs.jboss.org/hibernate/search/6.0/reference/en-US/html_single/#search-dsl-predicate-exists):

> There isn’t any built-in predicate to match documents for which a given field is null, but you can easily create one yourself by negating an `exists` predicate.
> 
> This can be achieved by using an `exists` predicate in a [`mustNot` clause in a boolean predicate](https://docs.jboss.org/hibernate/search/6.0/reference/en-US/html_single/#search-dsl-predicate-boolean-mustNot), or in an [`except` clause in a `matchAll` predicate](https://docs.jboss.org/hibernate/search/6.0/reference/en-US/html_single/#search-dsl-predicate-match-all-except).

So in your case:

```java
b.should(f.match().field(“groups.topic.id”).matching(topicId));
b.should(f.matchAll().except(f.exists().field(“groups”)));
b.minimumShouldMatchNumber(1);

```

---

<div class="post-metadata">

**Author:** ![yrodiere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/yrodiere/32/1760_2.png) [@yrodiere](https://discourse.hibernate.org/u/yrodiere)\
**Post date:** [November 9, 2020, 9:47am UTC](https://discourse.hibernate.org/t/missing-predicate-is-missing/4739/3 "2020-11-09T09:47:42Z")

</div>

Ok, it was definitely too early when I wrote my answer 🙂 I edited with a solution that actually does what you want, i.e.:

```java
b.should(f.match().field(“groups.topic.id”).matching(topicId));
b.should(f.matchAll().except(f.exists().field(“groups”)));
b.minimumShouldMatchNumber(1);

```

---

<div class="post-metadata">

**Author:** ![xpete](https://avatars.discourse-cdn.com/v4/letter/x/bbce88/32.png) [@xpete](https://discourse.hibernate.org/u/xpete)\
**Post date:** [November 22, 2020, 9:52pm UTC](https://discourse.hibernate.org/t/missing-predicate-is-missing/4739/4 "2020-11-22T21:52:56Z")

</div>

Thanks for the fast replay and sorry for only replying now. It worked perfectly.
