# Ordering of types in multitype search

**URL:** https://discuss.elastic.co/t/ordering-of-types-in-multitype-search/8293
**Category:** Elasticsearch
**Created:** [July 3, 2012, 5:19am UTC](https://discuss.elastic.co/t/ordering-of-types-in-multitype-search/8293 "2012-07-03T05:19:34Z")
**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: [July 3, 2012, 5:19am UTC](https://discuss.elastic.co/t/ordering-of-types-in-multitype-search/8293/1 "2012-07-03T05:19:34Z")

</div>

Hi there,

I am searching the data in multitypes and the mapping for the izap\_code is  
as follows :

_zip\_code :{_  
_"type":"long",_  
_"index":"analyzed"_

- 

```
          }*

```

And the request is as follows :

_$curl \_XGET  
'[http://localhost:9200/es\_index/Registereduser,Registeredcity,Registeredstate/\_search](http://localhost:9200/es_index/Registereduser,Registeredcity,Registeredstate/_search)'  
-d '{_  
_"query" : {_

- 

```
                 "text": {*

```

- 

```
                       "zip_code": {*

```

- 

```
                         "type": "phrase_prefix",*

```

- 

```
                         "query": "48703"*

```

- 

```
                                         }*

```

- 

```
                         }*

```

- 

```
       }*

```

_}'_  
\*  
\*

The type Registereduser does not have the field zip\_code, but the types  
Registeredcity and Registeredstate do have it, and the above query is not  
returning any response,

but if search without explicitly defining the types, then the results are  
retrieved.

_$curl \_XGET '[http://localhost:9200/es\_index/\_search](http://localhost:9200/es_index/_search)' -d '{_  
_"query" : {_

- 

```
                 "text": {*

```

- 

```
                       "zip_code": {*

```

- 

```
                         "type": "phrase_prefix",*

```

- 

```
                         "query": "48703"*

```

- 

```
                                         }*

```

- 

```
                         }*

```

- 

```
       }*

```

_}'_  
\*  
\*  
this is giving me the required results. and the surprising thing is if i  
change the order of the types, the top query, then it works. e.g :

_$curl \_XGET '[http://localhost:9200/es\_index/Registeredcity,Registeredstate](http://localhost:9200/es_index/Registeredcity,Registeredstate),  
 **Registereduser** /\_search' -d '{_  
_"query" : {_

- 

```
                 "text": {*

```

- 

```
                       "zip_code": {*

```

- 

```
                         "type": "phrase_prefix",*

```

- 

```
                         "query": "48703"*

```

- 

```
                                         }*

```

- 

```
                         }*

```

- 

```
       }*

```

_}'_  
\*  
\*  
Can anyone please explain why this is behaving like this ???? as I don't  
have the control over the ordering of the types.

Thanks  
Narinder Kaur

---

<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: [July 3, 2012, 5:37am UTC](https://discuss.elastic.co/t/ordering-of-types-in-multitype-search/8293/2 "2012-07-03T05:37:34Z")

</div>

Actually, zip\_code is present in Registereduser type, but it is having  
different mapping as

_zip\_code :{_  
_"type":"long",_  
_"index":"no"_

- 

```
          }*

```

- 
- 

so now I want to know, if elasticsearch is not searching the other records  
cause the Registereduser type was declared ahead of others and it does not  
have the zip\_code field indexed. According to me, it should behave like the  
field is not present there and should search the other types. but actually  
it is not doing so. its stopping the search in first type.

Help please.

On Tuesday, 3 July 2012 10:49:34 UTC+5:30, Narinder Kaur wrote:

> Hi there,
> 
> I am searching the data in multitypes and the mapping for the izap\_code is  
> as follows :
> 
> _zip\_code :{_  
> _"type":"long",_  
> _"index":"analyzed"_
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> And the request is as follows :
> 
> _$curl \_XGET '  
> [http://localhost:9200/es\_index/Registereduser,Registeredcity,Registeredstate/\_search](http://localhost:9200/es_index/Registereduser,Registeredcity,Registeredstate/_search)'  
> -d '{_  
> _"query" : {_
> 
> - 
> 
> ```
> "text": {*
> 
> ```
> 
> - 
> 
> ```
> "zip_code": {*
> 
> ```
> 
> - 
> 
> ```
> "type": "phrase_prefix",*
> 
> ```
> 
> - 
> 
> ```
> "query": "48703"*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> _}'_  
> \*  
> \*
> 
> The type Registereduser does not have the field zip\_code, but the types  
> Registeredcity and Registeredstate do have it, and the above query is not  
> returning any response,
> 
> but if search without explicitly defining the types, then the results are  
> retrieved.
> 
> _$curl \_XGET '[http://localhost:9200/es\_index/\_search](http://localhost:9200/es_index/_search)' -d '{_  
> _"query" : {_
> 
> - 
> 
> ```
> "text": {*
> 
> ```
> 
> - 
> 
> ```
> "zip_code": {*
> 
> ```
> 
> - 
> 
> ```
> "type": "phrase_prefix",*
> 
> ```
> 
> - 
> 
> ```
> "query": "48703"*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> _}'_  
> \*  
> \*  
> this is giving me the required results. and the surprising thing is if i  
> change the order of the types, the top query, then it works. e.g :
> 
> _$curl \_XGET '  
> [http://localhost:9200/es\_index/Registeredcity,Registeredstate,](http://localhost:9200/es_index/Registeredcity,Registeredstate,)_\*  
> Registereduser\*\*/\_search' -d '{\*  
> _"query" : {_
> 
> - 
> 
> ```
> "text": {*
> 
> ```
> 
> - 
> 
> ```
> "zip_code": {*
> 
> ```
> 
> - 
> 
> ```
> "type": "phrase_prefix",*
> 
> ```
> 
> - 
> 
> ```
> "query": "48703"*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> - 
> 
> ```
> }*
> 
> ```
> 
> _}'_  
> \*  
> \*  
> Can anyone please explain why this is behaving like this ???? as I don't  
> have the control over the ordering of the types.
> 
> Thanks  
> Narinder Kaur

---

<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:21am UTC](https://discuss.elastic.co/t/ordering-of-types-in-multitype-search/8293/3 "2017-07-06T03:21:41Z")

</div>


