Hello,
I want to filter the search results using non indexed field.
{
"_index" : "shipmentdata_v1",
"_type" : "_doc",
"_id" : "128Q711U",
"_score" : 1.0,
"_source" : {
"bundleId" : 13663,
"customerId" : 101456
}
}
for example customer Id.
I used below and it gives me an exception:
{
"query": { "match": { "customerId": 129759 } }
}
'
{
"error" : {
"root_cause" : [
{
"type" : "query_shard_exception",
"reason" : "failed to create query: {\n "match" : {\n "customerId" : {\n "query" : 129759,\n "operator" : "OR",\n "prefix_length" : 0,\n "max_expansions" : 50,\n "fuzzy_transpositions" : true,\n "lenient" : false,\n "zero_terms_query" : "NONE",\n "auto_generate_synonyms_phrase_query" : true,\n "boost" : 1.0\n }\n }\n}",
"index_uuid" : "2lkJMMvNQju8HmwMvPeo3A",
"index" : "shipmentdata_v1"
}
],
"type" : "search_phase_execution_exception",
"reason" : "all shards failed",
"phase" : "query",
"grouped" : true,
"failed_shards" : [
{
"shard" : 0,
"index" : "shipmentdata_v1",
"node" : "uGsbj81VRGmgHjgG4bgkKA",
"reason" : {
"type" : "query_shard_exception",
"reason" : "failed to create query: {\n "match" : {\n "customerId" : {\n "query" : 129759,\n "operator" : "OR",\n "prefix_length" : 0,\n "max_expansions" : 50,\n "fuzzy_transpositions" : true,\n "lenient" : false,\n "zero_terms_query" : "NONE",\n "auto_generate_synonyms_phrase_query" : true,\n "boost" : 1.0\n }\n }\n}",
"index_uuid" : "2lkJMMvNQju8HmwMvPeo3A",
"index" : "shipmentdata_v1",
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "Cannot search on field [customerId] since it is not indexed."
}
}
}
]
},
"status" : 400
}
I also tried to use
{
"filter": {
"script": {
"script": "_source['customerId'].value == 129759"
}
}
}
but it gave below exception:
{
"error" : {
"root_cause" : [
{
"type" : "parsing_exception",
"reason" : "Unknown key for a START_OBJECT in [filter].",
"line" : 3,
"col" : 11
}
],
"type" : "parsing_exception",
"reason" : "Unknown key for a START_OBJECT in [filter].",
"line" : 3,
"col" : 11
},
"status" : 400
}