# Search only works for terms without whitespace

**URL:** https://discourse.hibernate.org/t/search-only-works-for-terms-without-whitespace/5588
**Category:** Hibernate Search
**Created:** [August 5, 2021, 12:25pm UTC](https://discourse.hibernate.org/t/search-only-works-for-terms-without-whitespace/5588 "2021-08-05T12:25:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Lava](https://avatars.discourse-cdn.com/v4/letter/l/a4c791/32.png) [@Lava](https://discourse.hibernate.org/u/Lava)
#### Post date: [August 5, 2021, 12:25pm UTC](https://discourse.hibernate.org/t/search-only-works-for-terms-without-whitespace/5588/1 "2021-08-05T12:25:03Z")

</div>

I’m fairly new to Hibernate, so please tell me if I missed out on some information which you require.

My Problem is if I search for a description with 1 Term like “detailed” or “Description” I get a result, but if I keep a whitespace in between (“detailed Description”) I get no results, how would I accomplish this?

I have the following (shortend) Class “Part”

```auto
@Entity
@Indexed
public class Part {

@FullTextField(projectable = Projectable.YES)
private String description;

public String getDescription() {
    return description;
  }
  public void setDescription(String description) {
    this.description = description;
  }
}

```

And I have the following function inside a Dao Class

```auto
public List<Part> getParts() {
  EntityManager entityManager;
  SearchSession searchSession = Search.session(entityManager);
  ConvertToBean<List<?>, Part> converter = new ConvertToBean<List<?>, Part>(Part.class);
  return searchSession.search(Part.class).select( f -> f.composite(
          converter,
          f.field("description", String.class)
        ))
        .where(f -> f.bool(b -> {
            b.must(f.wildcard().field("description").matching(Util.withWildcard("detailed description")));
         })).fetchHits(1000)
  }

```

The persistence.xml includes all classes and the following properties

```auto
<properties>
            <property name="jboss.as.jpa.providerModule" value="application" />         
            <property name="hibernate.search.configuration_property_checking.strategy" value="ignore"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
            <property name="hibernate.show_sql" value="true"/>
</properties>

```

---

<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: [August 6, 2021, 7:10am UTC](https://discourse.hibernate.org/t/search-only-works-for-terms-without-whitespace/5588/2 "2021-08-06T07:10:00Z")

</div>

[Wildcard queries don’t (always) apply analysis](https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#search-dsl-predicate-wildcard), especially on Elasticsearch. Avoid them if you can.

See [lucene - Hibernate Search: How to use wildcards correctly? - Stack Overflow](https://stackoverflow.com/a/46904863/6692043) for a solution that leverages [analysis](https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#concepts-analysis) instead.

---

<div class="post-metadata">

### Author: ![Lava](https://avatars.discourse-cdn.com/v4/letter/l/a4c791/32.png) [@Lava](https://discourse.hibernate.org/u/Lava)
#### Post date: [August 6, 2021, 9:06am UTC](https://discourse.hibernate.org/t/search-only-works-for-terms-without-whitespace/5588/3 "2021-08-06T09:06:59Z")

</div>

Thanks for the tips regarding wildcard queries.

The solution to my Problem was to simply use @GenericField(projectable = Projectable.YES) instead of @FullTextField(). The problem why it didn’t work when I tried it was, that my build task build the index before applying the new change.
