I am using Elasticsearch latest version 5.6.4. I want to index the special characters and search them for the field title.special. Below is my mappings:
PUT index1
{
"mappings": {
"isContainer:false": {
"properties": {
"connectorSpecific": {
"properties": {
"title": {
"type": "text",
"store": true,
"fields": {
"special":{
"type": "text",
"analyzer": "special",
"search_analyzer": "special"
}
}
}
}
}
},
"settings": {
"index": {
"analysis": {
"analyzer": {
"special": {
"filter": [
"lowercase"
],
"tokenizer": "whitespace"
}
}
}
}
}
}
}
}
When I query in Kibana using term query,
GET index1/_search
{
"query": {
"term": {
"title.special": {
"value": "-unconstrained_net_use_inf_tw"
}
}
}
}
Nothing returns. But when I do a match search, documents do return. for eg.
GET index1/_search
{
"query": {
"match": {
"title.special": {
"value": "-unconstrained_net_use_inf_tw"
}
}
}
}
Is there something wrong in my mappings? How to make term query work on special characters like *,-,+ etc. Any help is appreciated
the term query works with the keyword datatype. title.special is a text datatype.to make term query work you have to change your title.special mapping Take a look here, the section called Why doesn’t the term query match my document? https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html