Does the datatype affects the searching


(narinder.izap) #1

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


(Shay Banon) #2

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.inwrote:

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


(system) #3