Q: Term query is giving null rows even if row is present I have this type of schema in my elastic search:
{
  "my_index": {
    "mappings": {
      "my_type": {
        "properties": {
          "mention_id": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "mentions": {
            "properties": {
              "name": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "score": {
                "type": "long"
              }
            }
          }
        }
      }
    }
  }
}

Data is stored in this format:
{
"_index": "globalmentionkb",
"_type": "globalmentionkb",
"_id": "ylWDd2kBUYncqPcTEE3d",
"_version": 1,
"_score": 1,
"_source": {
"mention_id": "GBMEN-19379",
"mentions": [
{
"name": " Mohatma Ghandi",
"score": 1
}
,
{
"name": " Biography of Mahatma Gandhi",
"score": 1
}
,
{
"name": " Svadeshi",
"score": 1
}
,
{
"name": " Gandhy",
"score": 1
}
,
{
"name": " Gandhi's work in South Africa",
"score": 1
}
,
{
"name": " Mohandas Gandhi",
"score": 1
}
,
{
"name": " Mahondas Gandhi",
"score": 1
}
,
{
"name": " Mahatama Ghandi",
"score": 1
}
,
{
"name": " Mahatman Gandhi",
"score": 1
}
,
{
"name": " Bapu Gandhi",
"score": 1
}
,
{
"name": " Mohandas Ghandi",
"score": 1
}
,
{
"name": " Mahatma Karamchand Gandhi",
"score": 1
}
,
{
"name": " મોહનદાસ કરમચંદ ગાંધી",
"score": 1
}
,
{
"name": " Gandhi",
"score": 1
}
,
{
"name": " Ghondi",
"score": 1
}
,
{
"name": " Little brown saint",
"score": 1
}
,
{
"name": " Mohandas KaramChand Gandhi",
"score": 1
}
,
{
"name": " Barrister mohandas karamchand gandhi",
"score": 1
}
,
{
"name": " Father of India",
"score": 1
}
,
{
"name": " Matahama Gandhi",
"score": 1
}
,
{
"name": " Mahâtmâ Gandhi",
"score": 1
}
,
{
"name": " Gandhi poppadom",
"score": 1
}
,
{
"name": " The little brown saint",
"score": 1
}
,
{
"name": " M.K. Gandhi",
"score": 1
}
,
{
"name": " Mohandus Ghandi",
"score": 1
}
,
{
"name": " M.K.Gandhi",
"score": 1
}
,
{
"name": " Mahatama Gandhi",
"score": 1
}
,
{
"name": " Mohandas K. Gandhi",
"score": 1
}
,
{
"name": " Mahatma Mohandas Karamchand Gandhi",
"score": 1
}
,
{
"name": " Mahatma gandhi",
"score": 1
}
,
{
"name": " M K Gandhi",
"score": 1
}
,
{
"name": " Gahndi",
"score": 1
}
,
{
"name": " Mahatma Ghadhi",
"score": 1
}
,
{
"name": " Gandhiji",
"score": 1
}
,
{
"name": " Mohandas K Gandhi",
"score": 1
}
,
{
"name": " Africian raga",
"score": 1
}
,
{
"name": " Gandhi, Mohandas K.",
"score": 1
}
,
{
"name": " M. K. Gandhi",
"score": 1
}
,
{
"name": " M. K. Ghandi",
"score": 1
}
,
{
"name": " MK Gandhi",
"score": 1
}
,
{
"name": " Mahatma Gandhi bibliography",
"score": 1
}
,
{
"name": " Ghandi",
"score": 1
}
,
{
"name": " Gandi's work in south africa",
"score": 1
}
,
{
"name": " Mohandas Karamchand Gandhi in South Africa",
"score": 1
}
,
{
"name": " Gnadhi",
"score": 1
}
,
{
"name": " Gandhi, Mohandas Karamchand",
"score": 1
}
,
{
"name": " Mahatma Ghandhi",
"score": 1
}
,
{
"name": " Gandhian Movement",
"score": 1
}
,
{
"name": " Mahatma Ghandi",
"score": 1
}
,
{
"name": " Putlibai",
"score": 1
}
,
{
"name": " Saint of Sabarmati",
"score": 1
}
,
{
"name": " Mohandas Karamchand Gandhi",
"score": 1
}
,
{
"name": " Mohandas \Mahatma\ Gandhi",
"score": 1
}
]
}
}

now i want to search only those entitys which has mention name "Gandhi".
{
  "query": {
    "term": {
      "mentions.name": "Gandhi" 
    }
  }
}

then it is giving null
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": [ ]
}
}

even if we have data.
can you tell me what should I do to get the exact term from my elastic search.

A: It looks like you use the standard analyzer which uses by default a token filter
"lowercase".
So there is no term Gandhi, only gandhi
This query should work: 
{
  "query": {
    "term": {
      "mentions.name": "gandhi" 
    }
  }
}

