Reputation: 396
I'm doing the following query to search some itens:
{
"filtered" : {
"query" : {
"match" : {
"name_db" : {
"query" : "Human",
"type" : "boolean"
}
}
},
"filter" : {
"terms" : {
"cat" : [ "B8E" ],
"execution" : "bool"
}
}
}
}
See that "cat" field? When it's something like "B8E" there are no results (even though it should), while when it's something like "320" the results are correct. What could be wrong? Why mixing letters and number would be a problem?
Thanks in advance.
PS: I'm new to elasticsearch
Upvotes: 0
Views: 404
Reputation: 217304
I'm pretty sure your field cat
is an analyzed
string and hence is being indexed in lowercase (and that makes no difference for numbers). If you try this query instead you'll get results.
{
"filtered" : {
"query" : {
"match" : {
"name_db" : {
"query" : "Human",
"type" : "boolean"
}
}
},
"filter" : {
"terms" : {
"cat" : [ "b8e" ], <--- search in lowercase
"execution" : "bool"
}
}
}
}
UPDATE
If you want to index the cat
field in uppercase so that you can search it using uppercase (e.g. "B8E"
), you need to change its mapping to being not_analyzed
, like this:
"cat": {
"type": "string",
"index": "not_analyzed"
}
Upvotes: 1