# Understanding substring matching

**URL:** <https://discuss.elastic.co/t/understanding-substring-matching/4199>\
**Category:** Elasticsearch\
**Created:** [April 7, 2011, 3:01pm UTC](https://discuss.elastic.co/t/understanding-substring-matching/4199 "2011-04-07T15:01:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JRoesner](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@JRoesner](https://discuss.elastic.co/u/JRoesner)\
**Post date:** [April 7, 2011, 3:01pm UTC](https://discuss.elastic.co/t/understanding-substring-matching/4199/1 "2011-04-07T15:01:50Z")

</div>

Hello Community,

we are pretty new to search using Lucene and voted ES over SOLR,  
followed by confusion regarding our simple usecase. Hopefully someone  
here can enlighten us.

What we'd like to achive is a location search based on geocoordinates  
combined with a full text pattern search at the same time. Here's what  
we did so far:

curl -XPOST ftl:9200/ft3  
curl -XPUT ftl:9200/ft3/\_mapping -d '{"pin":{"properties":{"location":  
{"type":"geo\_point"}},"index\_analyzer":"whitespace"}}'

We'd like to analyze every attributes of our objects, the whitespace  
analyzer seems to be the right one here and is hopefully correctly  
configured that way.

curl -XPUT ftl:9200/ft3/pin/1 -d '{"pin":{"location":{"lat":  
52.520791,"lon":13.4095},"attributes":{"name":"Restaurant  
Aussichtsplattform Berliner Fernsehturm","address":"Gontardstr.  
7","zipcode":"10178","city":"Berlin","country":"Germany"}}}'  
curl -XPUT ftl:9200/ft3/pin/2 -d '{"pin":{"location":{"lat":  
52.522671,"lon":13.40199},"attributes":{"name":"Hackescher  
Markt","address":"Am Zwirngraben  
1","zipcode":"10178","city":"Berlin","country":"Germany"}}}'

Two locations ... for search.

curl -XPOST ftl:9200/ft3/pin/\_search -d '{"query":{"match\_all":{}}}'

And yea, the come back. Even distance search works fine. Now next  
step.

curl -XPOST ftl:9200/ft3/pin/\_search -d '{"query":{"filtered":{"query":  
{"flt":{"like\_text":"Zwirngraben","min\_similarity":0.2}},"filter":  
{"geo\_distance":{"distance":"1km","pin.location":{"lat":  
52.517474,"lon":13.407612}}}}}}'

Still works. But if we give a substring only ...

'{"query":{"filtered":{"query":{"flt":  
{"like\_text":"Zwirn","min\_similarity":0.2}},"filter":{"geo\_distance":  
{"distance":"1km","pin.location":{"lat":52.517474,"lon":  
13.407612}}}}}}'

... no results are coming back.

AFAIK it's a problem of understanding how analyzers, tokenizers work.  
Question is: is it possible to easily achive the goal of fulltext  
pattern matching of all attributes combined with distance search?

Thx in advance.  
Jan

---

<div class="post-metadata">

**Author:** ![JRoesner](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@JRoesner](https://discuss.elastic.co/u/JRoesner)\
**Post date:** [April 7, 2011, 4:04pm UTC](https://discuss.elastic.co/t/understanding-substring-matching/4199/2 "2011-04-07T16:04:43Z")

</div>

First iteration solution seems to be something like that:

curl -XPOST ftl:9200/ft3 -d '{"index":{"number\_of\_shards":5,"analysis":  
{"filter":{"mynGram":{"type":"nGram","min\_gram":2,"max\_gram":  
10}},"analyzer":{"a1":{"type":"custom","tokenizer":"standard","filter":  
["lowercase","mynGram"]}}}}}}'  
curl -XPUT ftl:9200/ft3/\_mapping -d '{"pin":  
{"index\_analyzer":"a1","search\_analyzer":"standard","properties":  
{"location":{"type":"geo\_point"}}}}'

But I am quite unsure if that is the correct solution.

Any suggestions.

---

<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:08am UTC](https://discuss.elastic.co/t/understanding-substring-matching/4199/3 "2017-07-06T04:08:43Z")

</div>

Closed on July 6, 2017, 4:08am UTC


