# Filters and wildcards

**URL:** <https://discuss.elastic.co/t/filters-and-wildcards/9700>\
**Category:** Elasticsearch\
**Created:** [November 13, 2012, 5:43pm UTC](https://discuss.elastic.co/t/filters-and-wildcards/9700 "2012-11-13T17:43:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rjoys](https://avatars.discourse-cdn.com/v4/letter/r/9de0a6/32.png) [@Rjoys](https://discuss.elastic.co/u/Rjoys)\
**Post date:** [November 13, 2012, 5:43pm UTC](https://discuss.elastic.co/t/filters-and-wildcards/9700/1 "2012-11-13T17:43:20Z")

</div>

Hello,

I have another probably newbie question. I would like to achieve something  
like the following:

{  
"size": "20",  
"query": {  
"filtered": {  
"query": {"match\_all": {}},  
"filter": {  
"and": [  
{"term": {"Fields.FieldName": "contentbody"}},  
{"wildcard": {"Fields.Value": "direct\*"}}

```
          ]
       }
    }
}

```

}

where I am looking for all fields of contentbody having direct as a partial  
starting match.

Needless to say, out of the box, this query returns a 500 error stating No  
filters for wildcard are registered.

As the documents are somewhat dynamic in nature, my hope was to avoid  
specific mappings for the documents, but adding special config for wildcard  
filters is well within reason.

Thank you

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 13, 2012, 7:37pm UTC](https://discuss.elastic.co/t/filters-and-wildcards/9700/2 "2012-11-13T19:37:23Z")

</div>

You can use a QueryFilter to wrap your wildcard query, can't you?  
Or a prefixFilter ?

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 13 nov. 2012 à 18:43, Rjoys [rjoys@snapflow.com](mailto:rjoys@snapflow.com) a écrit :

> Hello,
> 
> I have another probably newbie question. I would like to achieve something like the following:
> 
> {  
> "size": "20",  
> "query": {  
> "filtered": {  
> "query": {"match\_all": {}},  
> "filter": {  
> "and": [  
> {"term": {"Fields.FieldName": "contentbody"}},  
> {"wildcard": {"Fields.Value": "direct\*"}}
> 
> ```
> ]
> }
> }
> }
> 
> ```
> 
> }
> 
> where I am looking for all fields of contentbody having direct as a partial starting match.
> 
> Needless to say, out of the box, this query returns a 500 error stating No filters for wildcard are registered.
> 
> As the documents are somewhat dynamic in nature, my hope was to avoid specific mappings for the documents, but adding special config for wildcard filters is well within reason.
> 
> ## Thank you

--

---

<div class="post-metadata">

**Author:** ![Rjoys](https://avatars.discourse-cdn.com/v4/letter/r/9de0a6/32.png) [@Rjoys](https://discuss.elastic.co/u/Rjoys)\
**Post date:** [November 13, 2012, 9:27pm UTC](https://discuss.elastic.co/t/filters-and-wildcards/9700/3 "2012-11-13T21:27:41Z")

</div>

The prefixFilter did the trick! Thank you.

I simply had to reconstruct my query builder to support exact matches  
versus "starts with"

On Tuesday, November 13, 2012 11:37:41 AM UTC-8, David Pilato wrote:

> You can use a QueryFilter to wrap your wildcard query, can't you?  
> Or a prefixFilter ?
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 13 nov. 2012 à 18:43, Rjoys \<[rj...@snapflow.com](mailto:rj...@snapflow.com) \<javascript:\>\> a  
> écrit :
> 
> Hello,
> 
> I have another probably newbie question. I would like to achieve something  
> like the following:
> 
> {  
> "size": "20",  
> "query": {  
> "filtered": {  
> "query": {"match\_all": {}},  
> "filter": {  
> "and": [  
> {"term": {"Fields.FieldName": "contentbody"}},  
> {"wildcard": {"Fields.Value": "direct\*"}}
> 
> ```
> ]
> }
> }
> }
> 
> ```
> 
> }
> 
> where I am looking for all fields of contentbody having direct as a  
> partial starting match.
> 
> Needless to say, out of the box, this query returns a 500 error stating No  
> filters for wildcard are registered.
> 
> As the documents are somewhat dynamic in nature, my hope was to avoid  
> specific mappings for the documents, but adding special config for wildcard  
> filters is well within reason.
> 
> Thank you
> 
> --

--

---

<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:** [July 6, 2017, 3:04am UTC](https://discuss.elastic.co/t/filters-and-wildcards/9700/4 "2017-07-06T03:04:29Z")

</div>


