# Does the datatype affects the searching

**URL:** https://discuss.elastic.co/t/does-the-datatype-affects-the-searching/8056
**Category:** Elasticsearch
**Created:** [June 12, 2012, 11:24am UTC](https://discuss.elastic.co/t/does-the-datatype-affects-the-searching/8056 "2012-06-12T11:24:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![narinder\_izap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narinder_izap/32/803_2.png) [@narinder\_izap](https://discuss.elastic.co/u/narinder_izap)
#### Post date: [June 12, 2012, 11:24am UTC](https://discuss.elastic.co/t/does-the-datatype-affects-the-searching/8056/1 "2012-06-12T11:24:44Z")

</div>

Hi there,  
I have 4-5 types in one index es\_data, in which some fields  
are common, but they are having different mapping in different types  
.

_type : type\_1_  
mapping :

{  
"id":integer,  
"name":"string",  
}

_type: type\_2_

{  
"id":string,  
"name":"string",  
}

_type: type\_3_

{  
"id":string,  
"name":"string",  
}

the query i am using is :

$ curl -XGET '[http://localhost:9200/es\_data/type\_1,type\_2,type\_3/\_search?'](http://localhost:9200/es_data/type_1,type_2,type_3/_search?')  
-d ' {  
{  
"query": {  
"constant\_score": {  
"query":  
{  
"bool": {  
"must": [  
{  
"text": {  
"id": {  
"type": "phrase\_prefix",  
"query": "162749"  
}  
}  
}  
]  
}  
}  
}  
}  
}  
}  
'

In results, I am just getting the documents of those of numeric id datatype  
_i.e of type\_1 only_, and if  
i run the query as

$ curl -XGET '[http://localhost:9200/es\_data/type\_2,type\_3/\_search?'](http://localhost:9200/es_data/type_2,type_3/_search?') -d ' {  
{  
"query": {  
"constant\_score": {  
"query":  
{  
"bool": {  
"must": [  
{  
"text": {  
"id": {  
"type": "phrase\_prefix",  
"query": "162749"  
}  
}  
}  
]  
}  
}  
}  
}  
}  
}  
'  
then i get the documentes from the _type\_2 and type\_3 only._  
\*  
\*  
_Can some one please help me why is this happening, I need to have all the  
results together, Is there any way except dropping the mapping and  
recreating the same mapping ???_

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [June 13, 2012, 6:56pm UTC](https://discuss.elastic.co/t/does-the-datatype-affects-the-searching/8056/2 "2012-06-13T18:56:41Z")

</div>

Don't do that if you search across types with different type per field.

On Tue, Jun 12, 2012 at 1:24 PM, Narinder Kaur [narinder.kaur@izap.in](mailto:narinder.kaur@izap.in)wrote:

> Hi there,  
> I have 4-5 types in one index es\_data, in which some fields  
> are common, but they are having different mapping in different types  
> .
> 
> _type : type\_1_  
> mapping :
> 
> {  
> "id":integer,  
> "name":"string",  
> }
> 
> _type: type\_2_
> 
> {  
> "id":string,  
> "name":"string",  
> }
> 
> _type: type\_3_
> 
> {  
> "id":string,  
> "name":"string",  
> }
> 
> the query i am using is :
> 
> $ curl -XGET '[http://localhost:9200/es\_data/type\_1,type\_2,type\_3/\_search?](http://localhost:9200/es_data/type_1,type_2,type_3/_search?)'  
> -d ' {  
> {  
> "query": {  
> "constant\_score": {  
> "query":  
> {  
> "bool": {  
> "must": [  
> {  
> "text": {  
> "id": {  
> "type": "phrase\_prefix",  
> "query": "162749"  
> }  
> }  
> }  
> ]  
> }  
> }  
> }  
> }  
> }  
> }  
> '
> 
> In results, I am just getting the documents of those of numeric id  
> datatype _i.e of type\_1 only_, and if  
> i run the query as
> 
> $ curl -XGET '[http://localhost:9200/es\_data/type\_2,type\_3/\_search?](http://localhost:9200/es_data/type_2,type_3/_search?)' -d ' {  
> {  
> "query": {  
> "constant\_score": {  
> "query":  
> {  
> "bool": {  
> "must": [  
> {  
> "text": {  
> "id": {  
> "type": "phrase\_prefix",  
> "query": "162749"  
> }  
> }  
> }  
> ]  
> }  
> }  
> }  
> }  
> }  
> }  
> '  
> then i get the documentes from the _type\_2 and type\_3 only._  
> \*  
> \*  
> _Can some one please help me why is this happening, I need to have all  
> the results together, Is there any way except dropping the mapping and  
> recreating the same mapping ???_

---

<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/does-the-datatype-affects-the-searching/8056/3 "2017-07-06T03:24:22Z")

</div>


