# Searching in case of leading wildcard searching

**URL:** <https://discuss.elastic.co/t/searching-in-case-of-leading-wildcard-searching/13670>\
**Category:** Elasticsearch\
**Created:** [September 18, 2013, 1:33pm UTC](https://discuss.elastic.co/t/searching-in-case-of-leading-wildcard-searching/13670 "2013-09-18T13:33:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ankit\_Jain](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@Ankit\_Jain](https://discuss.elastic.co/u/Ankit_Jain)\
**Post date:** [September 18, 2013, 1:33pm UTC](https://discuss.elastic.co/t/searching-in-case-of-leading-wildcard-searching/13670/1 "2013-09-18T13:33:58Z")

</div>

Hi All,

We have field col1 which contains values in below pattern.

aa:bb:cc  
aa:ee:ff  
aa:dd:gg

We are using QueryString query to search the record.

If we are searching for \*a:bb:cc , then query is returning all the above  
three records, but the expected record in only aa:bb:cc one. Even query is  
returning records which contains a, aa, aaa, etc.

Below is the query we are using:

String query = "{"query" : "  
+ QueryBuilders  
.queryString(  
"col1"  
+ ":"  
+ input

```
                                                )
                                                .analyzeWildcard(true)
                                                .defaultOperator(
                                                        Operator.AND)
                                                .toString() + "}";

```

Regards,  
Ankit Jain

--  
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:** ![Ankit\_Jain](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@Ankit\_Jain](https://discuss.elastic.co/u/Ankit_Jain)\
**Post date:** [September 18, 2013, 9:30pm UTC](https://discuss.elastic.co/t/searching-in-case-of-leading-wildcard-searching/13670/2 "2013-09-18T21:30:57Z")

</div>

Hi All,

If I am searching for aa:bb:cc, then query is returning exactly one record  
(expected behaviour).  
If I am searching for \*a:bb:cc, then query is returning more than expected  
results (unexpected behaviour).

We are using QueryString Query.

Regards,  
Ankit Jain

On Wednesday, 18 September 2013 19:03:58 UTC+5:30, Ankit Jain wrote:

> Hi All,
> 
> We have field col1 which contains values in below pattern.
> 
> aa:bb:cc  
> aa:ee:ff  
> aa:dd:gg
> 
> We are using QueryString query to search the record.
> 
> If we are searching for \*a:bb:cc , then query is returning all the above  
> three records, but the expected record in only aa:bb:cc one. Even query is  
> returning records which contains a, aa, aaa, etc.
> 
> Below is the query we are using:
> 
> String query = "{"query" : "  
> + QueryBuilders  
> .queryString(  
> "col1"  
> + ":"  
> + input
> 
> ```
> )
> .analyzeWildcard(true)
> .defaultOperator(
> Operator.AND)
> .toString() + "}";
> 
> ```
> 
> Regards,  
> Ankit Jain

--  
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:15am UTC](https://discuss.elastic.co/t/searching-in-case-of-leading-wildcard-searching/13670/3 "2017-07-06T02:15:41Z")

</div>


