# Single Character String Filter

**URL:** <https://discuss.dgraph.io/t/single-character-string-filter/14298>\
**Category:** GraphQL\
**Tags:** kind:question\
**Created:** [May 24, 2021, 2:01pm UTC](https://discuss.dgraph.io/t/single-character-string-filter/14298 "2021-05-24T14:01:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlnrrg](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jlnrrg/32/7538_2.png) [@jlnrrg](https://discuss.dgraph.io/u/jlnrrg)\
**Post date:** [May 24, 2021, 2:01pm UTC](https://discuss.dgraph.io/t/single-character-string-filter/14298/1 "2021-05-24T14:01:11Z")

</div>

I tried to run this filter, which obviously does not work, as my `name` field is `@search(by [term])` and my name is Julian 😄 .

```json
{
    "filter": {
        "name": {
            "anyofterms": "J"
        }
    }
}

```

My question is now, if there is an other way except regex to filter for single character or also show `Julian` when `Julia` was request.

---

<div class="post-metadata">

**Author:** ![chewxy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/chewxy/32/4339_2.png) [@chewxy](https://discuss.dgraph.io/u/chewxy)\
**Post date:** [May 26, 2021, 12:53am UTC](https://discuss.dgraph.io/t/single-character-string-filter/14298/2 "2021-05-26T00:53:44Z")

</div>

A term is generally a “word” (by some definition of what a “word” is). `"J"` is a single letter of a word. `anyofterms` is not the correct index to use. You want to use trigram indexing

---

<div class="post-metadata">

**Author:** ![jlnrrg](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jlnrrg/32/7538_2.png) [@jlnrrg](https://discuss.dgraph.io/u/jlnrrg)\
**Post date:** [June 18, 2021, 9:21am UTC](https://discuss.dgraph.io/t/single-character-string-filter/14298/3 "2021-06-18T09:21:06Z")

</div>

Thanks for providing a solution. As I am not familiar with the term `trigram indexing` and my google search was way over my head, I would appreciate it, if you could provide a filter code example, how that would look 😃

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [June 18, 2021, 12:50pm UTC](https://discuss.dgraph.io/t/single-character-string-filter/14298/4 "2021-06-18T12:50:30Z")

</div>

`@search(by [term, regexp])`

```auto
queryYourType(filter: { name: { regexp: "/Julian?/" } }) { ... }

```

Regexp is a whole language within itself. This example with a question mark says to match with or without the “n” character. You could make it any character replacing “n” with “.”

A regexp filter uses a trigram index under the hood which requires the regexp to be at least 3 characters.
