Can't search on specific field


(Laran Evans) #1

I'm unable to retrieve results using a filter on the field called "series":

This search returns 92 results:

GET /foos/Thing/_search
{
  "query": {
    "filtered": {
      "query": {
        "term": {
          "entityId": {
            "value": "105595155"
          }
        }
      }, 
      "filter": {
        "exists": {
          "field": "series"
        }
      }
    }
  }
}

The documents look like this:

{
        "_index": "foos",
        "_type": "Thing",
        "_id": "AU8pQXuqCDS84EhJEeld",
        "_score": 9.216088,
        "_source": {
           "metadata": {},
           "lastTimestamp": "2015-04-01T19:49:07.000Z",
           "series": "foo",
           "lastNormalizedTimestamp": "2015-04-01T19:49:07.000Z",
           "normalizedTimestamp": "2015-04-01T19:49:07.000Z",
           "entityId": "105595155",
           "value": 8,
           "timestamp": "2015-04-01T19:49:07.000Z"
        }
     },

This search, however, returns 0 results:

GET /foos/Thing/_search
{
  "query": {
    "filtered": {
      "query": {
        "term": {
          "entityId": {
            "value": "105595155"
          }
        }
      }, 
      "filter": {
        "term": {
          "series": "foo"
        }
      }
    }
  }
}

For the life of me, I haven't figured out why I can't retrieve results with a specific value in the "series" field.

Do you know why?


(Mike Simos) #2

Can you provide your mapping for /foo/Thing.


(Laran Evans) #3

GET /foo/_mapping/Thing

{
   "foo": {
      "mappings": {
         "Thing": {
            "properties": {
               "entityId": {
                  "type": "string",
                  "store": true
               },
               "lastNormalizedTimestamp": {
                  "type": "date",
                  "store": true,
                  "format": "dateOptionalTime"
               },
               "lastTimestamp": {
                  "type": "date",
                  "store": true,
                  "format": "dateOptionalTime"
               },
               "metadata": {
                  "type": "object"
               },
               "normalizedTimestamp": {
                  "type": "date",
                  "store": true,
                  "format": "dateOptionalTime"
               },
               "series": {
                  "type": "string",
                  "store": true
               },
               "timestamp": {
                  "type": "date",
                  "store": true,
                  "format": "dateOptionalTime"
               },
               "value": {
                  "type": "double",
                  "store": true
               }
            }
         }
      }
   }
}

(Ramy) #4

Try to change the mapping for that field to:

...
    "series": {
        "type": "string",
        "store": true,
        "index": "not_analyzed"
    }
...

(system) #5