Term doesn't work on all fileds?


(vodnok) #1

Hi,

New in elastic... (2-3 days testing)

I indexed some documents and here are the mapping :

{
"kumo" : {
"obj" : {
"properties" : {
"DT_CREATED" : {
"type" : "string"
},
"DT_SORT_1" : {
"type" : "string"
},
"C_OBJ_TYPE" : {
"type" : "string"
},
"query" : {
"dynamic" : "true",
"properties" : {
"term" : {
"dynamic" : "true",
"properties" : {
"L_INDEX_1" : {
"type" : "string"
}
}
}
}
},
"L_INDEX_BIS_1" : {
"type" : "string"
},
"DT_INDEXED" : {
"type" : "string"
},
"ID_INDEX_OBJECT" : {
"type" : "string"
},
"L_INDEX_3" : {
"type" : "string"
},
"ID_INDEX_OBJECT_DB" : {
"type" : "string"
},
"L_INDEX_2" : {
"type" : "string"
},
"L_INDEX_1" : {
"type" : "string"
}
}
}
}
}

Testing the query... i want to use "term" but it only works on L_INDEX_1. "term" on other fields return no result. When i see the mapping it seems logic because there is only :

"query" : {
"dynamic" : "true",
"properties" : {
"term" : {
"dynamic" : "true",
"properties" : {
"L_INDEX_1" : {
"type" : "string"
}
}
}
}
},

I didn't touch anything to the mapping, only indexing... I believed that it was automatic. So why i cannot use term on other field.

I use query_string too... here are my query json :

{
"query": {
"bool": {
"must" : {
"query_string" : {
"query" : "13160",
"fields" : [
"ID_INDEX_OBJECT_DB^1000",
"L_INDEX_1^100",
"L_INDEX_2^10",
"L_INDEX_3^1"
]
}
},
"must" : {
"term" : {
"C_OBJ_TYPE": "ISO_LOC"
}
}
}
}
}

I think it's related to :"Term Query - Matches documents that have fields that contain a a term (not analyzed). " But how to control this ?

Thank you,

Vodnok


(system) #2