title: Elasticsearch - searching with "keyword" type don't work
body: <p>I use Elasticsearch Java rest client 6.1. When I try to find logs due to a few parametrs than can be in one field I get nothing.</p>
  
  <p>Here is my code:</p>
  
  <pre><code> @Override
      public SearchResponse findLogsByValues(ElasticSearchLogRequest esLogRequest, Pageable pageable) {
          SearchRequest searchRequest = new SearchRequest("portal-logs-*");
  
          SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
          BoolQueryBuilder bqb = QueryBuilders.boolQuery();
   if (esLogRequest.getLevels() != null) {
              Iterator&lt;String&gt; iterator = esLogRequest.getLevels().iterator();
              int counter = 0;
              SpanOrQueryBuilder spanOrQueryBuilder = null;
              while (iterator.hasNext()) {
                  if (counter == 0) {
                      spanOrQueryBuilder = new SpanOrQueryBuilder(QueryBuilders.
                              spanTermQuery("level", iterator.next().toLowerCase()));
                  } else {
                      spanOrQueryBuilder.addClause(QueryBuilders.
                              spanTermQuery("level", iterator.next().toLowerCase()));
                  }
                  counter++;
              }
              bqb.filter(spanOrQueryBuilder);
          }
   try {
              searchResponse = client.search(searchRequest);
          } catch (IOException e) {
              e.printStackTrace();
          }
          return searchResponse;
      }
  </code></pre>
  
  <p>Here is my json request:</p>
  
  <pre><code>{
  
      "levels": ["TRACE","INFO"]
  
  }
  </code></pre>
  
  <p>Here is how log(object) looks like in ES:</p>
  
  <pre><code>{
      "code": 200,
      "error": "",
      "message": "",
      "data": {
          "content": [
                      {
                      "level": "INFO",
                      "module": "test module",
                      "ip": "192.168.3.93",
                      "thread": "test thread",
                      "sessionId": "1",
                      "office": "1",
                      "message": "test message 3",
                      "userName": "user",
                      "timeStamp": "2018-01-25T08:02:50.000Z",
                      "userLogin": "user",
                      "node": "first node",
                      "system": "super system 1",
                      "port": 9300,
                      "header": "test Header",
                      "submodule": "test submodule",
                      "location": {
                          "lon": -71.34,
                          "lat": 41.12
                      },
                      "operation": "some operation",
                      "device": "some device"
          }
          ],
          "totalPages": 1,
          "last": true,
          "totalElements": 0,
          "size": 0,
          "number": 0,
          "sort": null,
          "first": true,
          "numberOfElements": 0
      }
  }
  </code></pre>
  
  <p>Here is my mapping template:</p>
  
  <pre><code>  PUT _template/portal-logs
  {
    "template": "portal-logs-*",
    "settings": { "number_of_shards": 5 },
    "mappings": {
        "logs_info": {
          "_all": {
            "enabled": false
          },
          "properties": {
            "device": {"type": "keyword"},
            "header": {"type": "text"},
            "ip": {"type": "keyword"},
            "level": {"type": "keyword"},
            "location": {"type": "geo_point"},
            "message": {"type": "text"},
            "module": {"type": "keyword"},
            "node": {"type": "keyword"},
            "office": {"type": "keyword"},
            "operation": {"type": "keyword"},
            "port": {"type": "integer"},
            "sessionId": {"type": "keyword"},
            "submodule": {"type": "keyword"},
            "system": {"type": "keyword"},
            "thread": {"type": "keyword"},
            "timeStamp": {"type": "date"},
            "userLogin": {"type": "keyword"},
            "userName": {"type": "keyword"}
          }
        }
      }
    }
  </code></pre>
  
  <p>So when in mapping field "level" and set it as "text" - it works fine but when I set "keyword" - I receive an empty json. 
  I need that field "level" has a strict type "keyword" and it has to work when I want to get all logs that have "level" "INFO" or "TRACE". 
  What should I do in such case? Why with keyword it's not working?</p>