Query filter not working


(Sudhakar Sundar) #1

Hi Team,

Iam trying to build a simple query and filter but its not working.

{
"query": {
"bool": {
"must": [
{ "match": { "some_entry": "Not in" }}
],
"filter": [
{ "term": { "some_area": "XXX_YY" }}
]
}
}
}

Iam getting 0 hits while my index as many records. Iam trying to search a text in the field some_entry and if it matches I wanted to filter by some_area with exact value as XXX_YY, If I remove the filter Iam getting those records Iam getting the value, wanted to know what Iam doing wrong

Without filter

{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 434,
"max_score": 5.82006,
"hits": [
{
"_index": "logs2",
"_type": "log2",
"_id": "000001635084962",
"_score": 5.82006,
"_source": {
"some_area": "XXX_YY",
"logtypetext": "Internal",
"@timestamp": "2017-09-07T20:37:22.905Z",
"some_entry": " Circuit down - Circuit ID not found in the Database",
"@version": "1",
"request_id": "000001635084962"
}
},
{
"_index": "logs2",
"_type": "log2",
"_id": "000001010700627",
"_score": 5.82006,
"_source": {
"some_area": "XXX_YY",
"logtypetext": "Internal",
"some_entry_short": " =================================================",
"@timestamp": "2017-09-07T20:37:36.447Z",
"some_entry": " =====================================================================================\nThe customer is not in the list.\n=====================================================================================\n",
"@version": "1",
"request_id": "000001010700627"
}
},
...
}
}


(Sudhakar Sundar) #2

it looks like the term is case sensitive and with lower case Iam getting the results back. Thanks


(Ivan Brusic) #3

Term queries do not analyze the query term, whereas match queries will. Use
term queries only for exact matches.


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.