Ordering of types in multitype search


(narinder.izap) #1

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'
-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' -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,
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


(narinder.izap) #2

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'
-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' -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,
*
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


(system) #3