# Relevancy in results when searching by wildcard

**URL:** <https://discuss.elastic.co/t/relevancy-in-results-when-searching-by-wildcard/4507>\
**Category:** Elasticsearch\
**Created:** [May 31, 2011, 6:15pm UTC](https://discuss.elastic.co/t/relevancy-in-results-when-searching-by-wildcard/4507 "2011-05-31T18:15:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@Michael](https://discuss.elastic.co/u/Michael)\
**Post date:** [May 31, 2011, 6:15pm UTC](https://discuss.elastic.co/t/relevancy-in-results-when-searching-by-wildcard/4507/1 "2011-05-31T18:15:22Z")

</div>

Hi everyone

I'm have index with such data

{"id": "some\_id",  
"owner\_id": "some\_owner\_id",  
"created": "{some\_creation\_date}",  
"tag": "some\_tag",  
"fields":{  
{"first\_name": "michael",  
"last\_name":"girnyak",  
"name":"michael girnyak",  
"phone": "66666666"}  
}  
{"id": "some\_id",  
"owner\_id": "some\_owner\_id",  
"created": "{some\_creation\_date}",  
"tag": "some\_tag",  
"fields":{  
"first\_name": "anton",  
"last\_name": "koval",  
"name": "anton koval",  
"phone": "5555555"}  
}  
{"id": "some\_id",  
"owner\_id": "some\_owner\_id",  
"created": "{some\_creation\_date}",  
"tag": "some\_tag",  
"fields":{  
{"first\_name": "brenda",  
"last\_name":"cristin",  
"name":"brenda cristin",  
"phone": "77777777"}  
}  
with mapping such as  
{  
"contact": {  
"\_all" : { "enabled" : False },  
"\_source" : { "enabled" : False },  
"properties" : {  
"id": {  
"type": "string",  
"store": "yes"  
},  
"owner\_id": {  
"type": "string",  
"index": "not\_analyzed",  
},  
"created": {  
"type": "date",  
"index": "not\_analyzed",  
"format" : "yyyy-MM-dd'T'HH:mm:ssZ"  
},  
"tag":{  
"type": "string",  
"index": "not\_analyzed",  
"omit\_term\_freq\_and\_positions": "true",  
},  
"fields": {  
"type": "object",  
"properties" : {  
"first\_name": {  
"type": "string",  
"index": "not\_analyzed",  
"omit\_term\_freq\_and\_positions": "true"  
},  
"last\_name": {  
"type": "string",  
"index": "not\_analyzed",  
"omit\_term\_freq\_and\_positions": "true"  
},  
"name": {  
"type": "string",  
"index": "not\_analyzed",  
"omit\_term\_freq\_and\_positions": "true"  
},  
"phone":  
"type": "string",  
"index": "not\_analyzed",  
"omit\_term\_freq\_and\_positions": "true"  
},  
}  
}  
}

and try search by wildcard  
{"query": {"wildcard": {"fields.first\_name": "_a_"}}}  
I want to have results in this direction  
first item with first\_name Anton  
second item with first\_name michAel  
third item with first\_name brendA  
the search criteria must go from start of first\_name field to end

what I need to do to get such results?  
maybe I need to use some analyzer or some specific boosting  
please help me with this I will be very appreciate

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [June 1, 2011, 9:28am UTC](https://discuss.elastic.co/t/relevancy-in-results-when-searching-by-wildcard/4507/2 "2011-06-01T09:28:34Z")

</div>

Hi Michael

> and try search by wildcard  
> {"query": {"wildcard": {"fields.first\_name": "_a_"}}}  
> I want to have results in this direction  
> first item with first\_name Anton  
> second item with first\_name michAel  
> third item with first\_name brendA  
> the search criteria must go from start of first\_name field to end
> 
> what I need to do to get such results?  
> maybe I need to use some analyzer or some specific boosting  
> please help me with this I will be very appreciate

All wildcard matches return the score: 1.

If you want to use relevancy with partial matches, then you should look  
at using the ngram or edge-ngram analyzers

clint

---

<div class="post-metadata">

**Author:** ![Michael](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@Michael](https://discuss.elastic.co/u/Michael)\
**Post date:** [June 1, 2011, 1:19pm UTC](https://discuss.elastic.co/t/relevancy-in-results-when-searching-by-wildcard/4507/3 "2011-06-01T13:19:05Z")

</div>

What actually I need to do? Could you explain me? Or may you give me some  
example?  
I try nGram analyzer but it don't give an results for me, the score is still  
same for each of index data item. =((

On Wed, Jun 1, 2011 at 12:28 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:

> Hi Michael
> 
> > and try search by wildcard  
> > {"query": {"wildcard": {"fields.first\_name": "_a_"}}}  
> > I want to have results in this direction  
> > first item with first\_name Anton  
> > second item with first\_name michAel  
> > third item with first\_name brendA  
> > the search criteria must go from start of first\_name field to end
> > 
> > what I need to do to get such results?  
> > maybe I need to use some analyzer or some specific boosting  
> > please help me with this I will be very appreciate
> 
> All wildcard matches return the score: 1.
> 
> If you want to use relevancy with partial matches, then you should look  
> at using the ngram or edge-ngram analyzers
> 
> clint

---

<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, 4:05am UTC](https://discuss.elastic.co/t/relevancy-in-results-when-searching-by-wildcard/4507/4 "2017-07-06T04:05:02Z")

</div>


