# Wildcard query not working

**URL:** <https://discuss.elastic.co/t/wildcard-query-not-working/14568>\
**Category:** Elasticsearch\
**Created:** [November 24, 2013, 6:18pm UTC](https://discuss.elastic.co/t/wildcard-query-not-working/14568 "2013-11-24T18:18:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackpark](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jackpark](https://discuss.elastic.co/u/jackpark)\
**Post date:** [November 24, 2013, 6:18pm UTC](https://discuss.elastic.co/t/wildcard-query-not-working/14568/1 "2013-11-24T18:18:50Z")

</div>

Simple question from a beginner.  
I store a document that looks like this:  
{"locator":"CO2.CausalAssociation.ClimateChange",  
"nameString":"CO2 causes Climate Change",  
"instanceOf":"AssociationType",  
"sourceTopic":"CO2",  
"targetTopic":"ClimateChange"  
}

and can prove it is there (that query brought up with a match query.

Using QueryBuilders, I get this query string

{  
"wildcard" : {  
"locator" : {  
"wildcard" : "CO2.CausalAssociation\*"  
}  
}

Earlier, I tried the simplest possible string, as suggested in the ES  
documentation:

{"wildcard": {"locator":"CO2.CausalAssociation\*"}}

Both query strings fail to match the given document.

In my code, I do not add any mappings to the index as I create. I am  
down to wondering why match will work, but wildcard will not.

Thanks in advance for any ideas.

Jack

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 24, 2013, 6:30pm UTC](https://discuss.elastic.co/t/wildcard-query-not-working/14568/2 "2013-11-24T18:30:03Z")

</div>

Probably because your fields are analyzed (standard analyzer by default) and wildcard query are not analyzed.

You should perhaps not analyze your fields.

That said, wildcard queries are slow. You should consider ngrams.

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

Le 24 nov. 2013 à 19:18, Jack Park [jackpark@topicquests.org](mailto:jackpark@topicquests.org) a écrit :

Simple question from a beginner.  
I store a document that looks like this:  
{"locator":"CO2.CausalAssociation.ClimateChange",  
"nameString":"CO2 causes Climate Change",  
"instanceOf":"AssociationType",  
"sourceTopic":"CO2",  
"targetTopic":"ClimateChange"  
}

and can prove it is there (that query brought up with a match query.

Using QueryBuilders, I get this query string

{  
"wildcard" : {  
"locator" : {  
"wildcard" : "CO2.CausalAssociation\*"  
}  
}

Earlier, I tried the simplest possible string, as suggested in the ES  
documentation:

{"wildcard": {"locator":"CO2.CausalAssociation\*"}}

Both query strings fail to match the given document.

In my code, I do not add any mappings to the index as I create. I am  
down to wondering why match will work, but wildcard will not.

Thanks in advance for any ideas.

Jack

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jackpark](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jackpark](https://discuss.elastic.co/u/jackpark)\
**Post date:** [November 24, 2013, 6:33pm UTC](https://discuss.elastic.co/t/wildcard-query-not-working/14568/3 "2013-11-24T18:33:46Z")

</div>

That helps. As a beginner, I presume that means I must put a map in  
which says not to analyize, or to generate an ngrams.

Thanks!

On Sun, Nov 24, 2013 at 10:30 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Probably because your fields are analyzed (standard analyzer by default) and wildcard query are not analyzed.
> 
> You should perhaps not analyze your fields.
> 
> That said, wildcard queries are slow. You should consider ngrams.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 24 nov. 2013 à 19:18, Jack Park [jackpark@topicquests.org](mailto:jackpark@topicquests.org) a écrit :
> 
> Simple question from a beginner.  
> I store a document that looks like this:  
> {"locator":"CO2.CausalAssociation.ClimateChange",  
> "nameString":"CO2 causes Climate Change",  
> "instanceOf":"AssociationType",  
> "sourceTopic":"CO2",  
> "targetTopic":"ClimateChange"  
> }
> 
> and can prove it is there (that query brought up with a match query.
> 
> Using QueryBuilders, I get this query string
> 
> {  
> "wildcard" : {  
> "locator" : {  
> "wildcard" : "CO2.CausalAssociation\*"  
> }  
> }
> 
> Earlier, I tried the simplest possible string, as suggested in the ES  
> documentation:
> 
> {"wildcard": {"locator":"CO2.CausalAssociation\*"}}
> 
> Both query strings fail to match the given document.
> 
> In my code, I do not add any mappings to the index as I create. I am  
> down to wondering why match will work, but wildcard will not.
> 
> Thanks in advance for any ideas.
> 
> Jack
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jackpark](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jackpark](https://discuss.elastic.co/u/jackpark)\
**Post date:** [November 24, 2013, 8:10pm UTC](https://discuss.elastic.co/t/wildcard-query-not-working/14568/4 "2013-11-24T20:10:05Z")

</div>

An experimental solution was simply to go in and create a mapping for  
the affected fields and set them to not-analyzed. I learned the hard  
way that the Java API for setting mappings wants the index type; I am  
now wondering how to do that across all possible types, and, for that  
matter, across all possible indexes in a node.

On Sun, Nov 24, 2013 at 10:33 AM, Jack Park [jackpark@topicquests.org](mailto:jackpark@topicquests.org) wrote:

> That helps. As a beginner, I presume that means I must put a map in  
> which says not to analyize, or to generate an ngrams.
> 
> Thanks!
> 
> On Sun, Nov 24, 2013 at 10:30 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:
> 
> > Probably because your fields are analyzed (standard analyzer by default) and wildcard query are not analyzed.
> > 
> > You should perhaps not analyze your fields.
> > 
> > That said, wildcard queries are slow. You should consider ngrams.
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 24 nov. 2013 à 19:18, Jack Park [jackpark@topicquests.org](mailto:jackpark@topicquests.org) a écrit :
> > 
> > Simple question from a beginner.  
> > I store a document that looks like this:  
> > {"locator":"CO2.CausalAssociation.ClimateChange",  
> > "nameString":"CO2 causes Climate Change",  
> > "instanceOf":"AssociationType",  
> > "sourceTopic":"CO2",  
> > "targetTopic":"ClimateChange"  
> > }
> > 
> > and can prove it is there (that query brought up with a match query.
> > 
> > Using QueryBuilders, I get this query string
> > 
> > {  
> > "wildcard" : {  
> > "locator" : {  
> > "wildcard" : "CO2.CausalAssociation\*"  
> > }  
> > }
> > 
> > Earlier, I tried the simplest possible string, as suggested in the ES  
> > documentation:
> > 
> > {"wildcard": {"locator":"CO2.CausalAssociation\*"}}
> > 
> > Both query strings fail to match the given document.
> > 
> > In my code, I do not add any mappings to the index as I create. I am  
> > down to wondering why match will work, but wildcard will not.
> > 
> > Thanks in advance for any ideas.
> > 
> > Jack
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:05am UTC](https://discuss.elastic.co/t/wildcard-query-not-working/14568/5 "2017-07-06T02:05:06Z")

</div>


