# Search for word without spaces if query contains spaces

**URL:** https://discuss.elastic.co/t/search-for-word-without-spaces-if-query-contains-spaces/45342
**Category:** Elasticsearch
**Created:** [March 24, 2016, 12:14pm UTC](https://discuss.elastic.co/t/search-for-word-without-spaces-if-query-contains-spaces/45342 "2016-03-24T12:14:50Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Lukas\_Zaiser](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lukas\_Zaiser](https://discuss.elastic.co/u/Lukas_Zaiser)
#### Post date: [March 24, 2016, 12:14pm UTC](https://discuss.elastic.co/t/search-for-word-without-spaces-if-query-contains-spaces/45342/1 "2016-03-24T12:14:51Z")

</div>

Hello maybe someone can help me,

I'm using Multimatch Query with Fuzzy search to build a search and it's working pretty good.

My query:

`{"from":0,"size":30,"query": {"bool":{"should":[{"multi_match":{ "query":"Farbe", "fields": ["name1","name2","city1","postalCode"]}}, {"match":{"name1":{"_name":"name1","query":"Farbe","fuzziness":1,"prefix_length":3,"max_expansions":50}}}, {"match":{"name2":{"_name":"name2","query":"Farbe","fuzziness":1,"prefix_length":3,"max_expansions":50}}}, {"match":{"city1":{"_name":"city1","query":"Farbe","fuzziness":1,"prefix_length":3,"max_expansions":50}}}, {"match":{"postalCode":{"_name":"postalCode","query":"Farbe","fuzziness":1,"prefix_length":3,"max_expansions":50}}}]}}}`

The only thing that doesn't work is if I search for e.g.

Mexicocity  
when the correct entry would be: Mexico City.

I think I need an analyzer for my search term.

Is this kind of search correction possible with ES?  
Would be great if I don't have to modify my data definition in the database.

---

<div class="post-metadata">

### Author: ![hkhalidz](https://avatars.discourse-cdn.com/v4/letter/h/dc4da7/32.png) [@hkhalidz](https://discuss.elastic.co/u/hkhalidz)
#### Post date: [May 11, 2016, 9:55pm UTC](https://discuss.elastic.co/t/search-for-word-without-spaces-if-query-contains-spaces/45342/2 "2016-05-11T21:55:09Z")

</div>

You can use the **wildcard** parameter for this. Here's an example:

`{ "wildcard": { "fieldname": "*need*" } }`

This will match every word that has the word need in it.

---

<div class="post-metadata">

### Author: ![Mallikarjuna\_J\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mallikarjuna_j_s/32/51778_2.png) [@Mallikarjuna\_J\_S](https://discuss.elastic.co/u/Mallikarjuna_J_S)
#### Post date: [April 2, 2017, 7:19pm UTC](https://discuss.elastic.co/t/search-for-word-without-spaces-if-query-contains-spaces/45342/3 "2017-04-02T19:19:34Z")

</div>

Hi Lukas,

Here is the link to one of the post that solves your problem hope this helps.

> **[Elasticsearch \[How to search for a word without spaces, if word itself is...](https://arjunjs.wordpress.com/2017/04/02/elasticsearch-how-to-search-for-a-word-without-spaces-if-word-itself-is-combination-of-two-different-words/?preview_id=122&preview_nonce=7b0c3efe95)**
>
> I was using  Elasticsearch for search and there was this specific problem I encountered in one of the applications I was working on. So, the problem was this there are numerous words in English tha…

---

<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 5, 2017, 10:01pm UTC](https://discuss.elastic.co/t/search-for-word-without-spaces-if-query-contains-spaces/45342/4 "2017-07-05T22:01:33Z")

</div>


