# Stree Address Queries

**URL:** <https://discuss.elastic.co/t/stree-address-queries/16585>\
**Category:** Elasticsearch\
**Created:** [March 25, 2014, 1:45pm UTC](https://discuss.elastic.co/t/stree-address-queries/16585 "2014-03-25T13:45:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henri\_van\_den\_Bulk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henri_van_den_bulk/32/1671_2.png) [@Henri\_van\_den\_Bulk](https://discuss.elastic.co/u/Henri_van_den_Bulk)\
**Post date:** [March 25, 2014, 1:45pm UTC](https://discuss.elastic.co/t/stree-address-queries/16585/1 "2014-03-25T13:45:07Z")

</div>

I have a field that contains the full address, e.g. 1200 S FUN ST.  
I need to accomplish two type of searches one a suggest search with  
synonyms so that users can type ahead "1200 Fun ave" which can be "1200 Fun  
Avenue" or "1200 E Fun Ave". How have other accomplished this type of  
search and what type of tokenizing needs to be used?

One my second type is more of a full text exact search but my search  
results don't match correctly. I 1st setup the field fullAddress as a  
"string" map:

- fullAddress:  
{
  - type: "string"  
},

When I query for say Fun St I get results that include S Fun St and N Fun  
St and plain Fun St.

"text": {  
"fullAddress": "Fun St"  
}

However, when I then try to search for "S Fun St" it result also results  
with "Fun St" and other addresses with "S" in it.

"text": {  
"fullAddress": "S Fun St"  
}

From reading some other posts they suggest using a mapping where the field  
is not analyzed. So I changed the field to the following:

- fullAddress:  
{
  - type: "string",
  - index: "not\_analyzed",
  - omit\_norms: true,
  - index\_options: "docs"  
},

But now when I do the query I don't get any results unless the I do an  
exact query that does a complete match. Any thoughts?

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/67310fc1-082b-41de-9b92-4bb70f539397%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/67310fc1-082b-41de-9b92-4bb70f539397%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [March 26, 2014, 8:25pm UTC](https://discuss.elastic.co/t/stree-address-queries/16585/2 "2014-03-26T20:25:05Z")

</div>

You probably want to "upgrade" to the match query - "text" queries are  
older and no longer exist in 1.x. But anyway when you query:

"match": { "f": "S Fun St" }

You are effectively doing (roughly):

f=S or f=fun or f=St

You could make it do AND if you want (in which case a match is only found  
if the document/field value contains all terms):

{  
"match" : {  
"f" : {  
"query" : "S Fun St",  
"operator" : "and"  
}  
}  
}

You could also do OR with a minimum\_should\_match parameter to specify how  
many of the individual terms should match the document/field value:

{  
"match" : {  
"f" : {  
"query" : "S Fun St",  
"minimum\_should\_match" : 2  
}  
}  
}

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/611427d1-cf08-4fec-a79d-b725a989ca86%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/611427d1-cf08-4fec-a79d-b725a989ca86%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Henri\_van\_den\_Bulk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henri_van_den_bulk/32/1671_2.png) [@Henri\_van\_den\_Bulk](https://discuss.elastic.co/u/Henri_van_den_Bulk)\
**Post date:** [April 3, 2014, 1:35am UTC](https://discuss.elastic.co/t/stree-address-queries/16585/3 "2014-04-03T01:35:21Z")

</div>

Thanks for the great explanation. Is there also a comparable equivalent  
when using query string?

On Wednesday, March 26, 2014 2:25:05 PM UTC-6, Binh Ly wrote:

> You probably want to "upgrade" to the match query - "text" queries are  
> older and no longer exist in 1.x. But anyway when you query:
> 
> "match": { "f": "S Fun St" }
> 
> You are effectively doing (roughly):
> 
> f=S or f=fun or f=St
> 
> You could make it do AND if you want (in which case a match is only found  
> if the document/field value contains all terms):
> 
> {  
> "match" : {  
> "f" : {  
> "query" : "S Fun St",  
> "operator" : "and"  
> }  
> }  
> }
> 
> You could also do OR with a minimum\_should\_match parameter to specify how  
> many of the individual terms should match the document/field value:
> 
> {  
> "match" : {  
> "f" : {  
> "query" : "S Fun St",  
> "minimum\_should\_match" : 2  
> }  
> }  
> }

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/cd425185-e2e0-4d8f-ba1c-c357b54cd4d1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cd425185-e2e0-4d8f-ba1c-c357b54cd4d1%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:38am UTC](https://discuss.elastic.co/t/stree-address-queries/16585/4 "2017-07-06T01:38:37Z")

</div>


