# Unable to get the results when searchtext containing spaces

**URL:** <https://discuss.elastic.co/t/unable-to-get-the-results-when-searchtext-containing-spaces/8042>\
**Category:** Elasticsearch\
**Created:** [June 11, 2012, 1:14pm UTC](https://discuss.elastic.co/t/unable-to-get-the-results-when-searchtext-containing-spaces/8042 "2012-06-11T13:14:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aruna](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@Aruna](https://discuss.elastic.co/u/Aruna)\
**Post date:** [June 11, 2012, 1:14pm UTC](https://discuss.elastic.co/t/unable-to-get-the-results-when-searchtext-containing-spaces/8042/1 "2012-06-11T13:14:20Z")

</div>

Hi,  
I have installed elasticsearch-river-couchdb and node  
elasticsearchclient. Now i am searching data in couchdb using node  
elasticsearchclient. I have JSON structure like this,

{  
first\_name: "aruna vennapusa",  
interests: [ {name: "pets", level: 5},  
{topic: "es", degree: "strong"}  
] ,  
designation: "SE",  
company: "DOM",  
salary: 200000  
}

and i have written code like this,  
var searchText="aruna";  
testSearch = function() {  
var qryObj = {  
"size" : 50,  
"query" : {  
"wildcard" : {  
"\_all" :searchText  
}  
}  
};  
elasticSearchClient.search("test", "",qryObj, size)  
.on('data', function(data) {  
console.log("Search: "+data)  
assert.ok(JSON.parse(data), "testSearch failed.")  
})  
.exec()  
}

If i search for aruna i am able to get the data. but if the part of  
the searchText contains space, i am unable to get the results. suppose  
searchText is "aruna vennapusa". please anyone suggest me to to get  
those results.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 11, 2012, 8:32pm UTC](https://discuss.elastic.co/t/unable-to-get-the-results-when-searchtext-containing-spaces/8042/2 "2012-06-11T20:32:56Z")

</div>

The field first name is tokenized in two terms aruna and vennapusa  
You can search for "aruna vennapusa" with a text query

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

But not with wildcard as it's not analyzed.

If you really want to use wildcard you will have to change the mapping for  
this field, setting it to index: not\_analyzed

David.

> -----Message d'origine-----  
> De : [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)  
> [[mailto:elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)] De la part de Aruna  
> Envoyé : lundi 11 juin 2012 15:14  
> À : elasticsearch  
> Objet : unable to get the results when searchtext containing spaces
> 
> Hi,  
> I have installed elasticsearch-river-couchdb and node  
> elasticsearchclient. Now i am searching data in couchdb using node  
> elasticsearchclient. I have JSON structure like this,
> 
> {  
> first\_name: "aruna vennapusa",  
> interests: [ {name: "pets", level: 5},  
> {topic: "es", degree: "strong"}  
> ] ,  
> designation: "SE",  
> company: "DOM",  
> salary: 200000  
> }
> 
> and i have written code like this,  
> var searchText="aruna";  
> testSearch = function() {  
> var qryObj = {  
> "size" : 50,  
> "query" : {  
> "wildcard" : {  
> "\_all" :searchText  
> }  
> }  
> };  
> elasticSearchClient.search("test", "",qryObj, size)  
> .on('data', function(data) {  
> console.log("Search: "+data)  
> assert.ok(JSON.parse(data), "testSearch failed.")  
> })  
> .exec()  
> }
> 
> If i search for aruna i am able to get the data. but if the part of the  
> searchText contains space, i am unable to get the results. suppose  
> searchText is "aruna vennapusa". please anyone suggest me to to get  
> those results.

---

<div class="post-metadata">

**Author:** ![Aruna](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@Aruna](https://discuss.elastic.co/u/Aruna)\
**Post date:** [June 13, 2012, 4:05am UTC](https://discuss.elastic.co/t/unable-to-get-the-results-when-searchtext-containing-spaces/8042/3 "2012-06-13T04:05:00Z")

</div>

Thanks David. I tried with text query now its working

On Tuesday, June 12, 2012 2:02:56 AM UTC+5:30, David Pilato wrote:

> The field first name is tokenized in two terms aruna and vennapusa  
> You can search for "aruna vennapusa" with a text query  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html)  
> But not with wildcard as it's not analyzed.
> 
> If you really want to use wildcard you will have to change the mapping for  
> this field, setting it to index: not\_analyzed
> 
> David.
> 
> > -----Message d'origine-----  
> > De : [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)  
> > [[mailto:elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)] De la part de Aruna  
> > Envoyé : lundi 11 juin 2012 15:14  
> > À : elasticsearch  
> > Objet : unable to get the results when searchtext containing spaces
> > 
> > Hi,  
> > I have installed elasticsearch-river-couchdb and node  
> > elasticsearchclient. Now i am searching data in couchdb using node  
> > elasticsearchclient. I have JSON structure like this,
> > 
> > {  
> > first\_name: "aruna vennapusa",  
> > interests: [ {name: "pets", level: 5},  
> > {topic: "es", degree: "strong"}  
> > ] ,  
> > designation: "SE",  
> > company: "DOM",  
> > salary: 200000  
> > }
> > 
> > and i have written code like this,  
> > var searchText="aruna";  
> > testSearch = function() {  
> > var qryObj = {  
> > "size" : 50,  
> > "query" : {  
> > "wildcard" : {  
> > "\_all" :searchText  
> > }  
> > }  
> > };  
> > elasticSearchClient.search("test", "",qryObj, size)  
> > .on('data', function(data) {  
> > console.log("Search: "+data)  
> > assert.ok(JSON.parse(data), "testSearch failed.")  
> > })  
> > .exec()  
> > }
> > 
> > If i search for aruna i am able to get the data. but if the part of the  
> > searchText contains space, i am unable to get the results. suppose  
> > searchText is "aruna vennapusa". please anyone suggest me to to get  
> > those results.

---

<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, 3:24am UTC](https://discuss.elastic.co/t/unable-to-get-the-results-when-searchtext-containing-spaces/8042/4 "2017-07-06T03:24:41Z")

</div>


