Problem with filter when term is with letters and numbers


(Gustavo Amgarten De Lêdo) #1

Hello. 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?

EDIT: It's not only when mixing letters and numbers, there are also no results and "cat" has only letters. For instance: BFD. It only works when cat is only numbers.

Thanks in advance.

PS: I'm new to elasticsearch


(Ivan Brusic) #2

The field was probably a number field or analyzed as a string field. Verify
using the mapping API that the "cat" field is a string and not_analyzed (or
at least uses a keyword tokenizer). If you use dynamic mappings and the
first indexed document had pure numbers for "cat", it will map as a
numerical field.


(system) #3