Exact match using a term query is not working if the field has numbers in it

  1. I have a mapping set up for a field called "sku". It is configured as
    not_analyzed such that I can do exact matches on it

.startObject("sku")
.field("index", "not_analyzed")
.field("type", "string")
.endObject()

  1. The database contains a document where sku=test1.test and one where
    sku=testx.test

  2. This query returns 0 results
    {
    "query": {
    "term": {
    "sku": "test1.test"
    }
    }
    }

  3. This query returns 1 result
    {
    "query": {
    "term": {
    "sku": "testx.test"
    }
    }
    }

  4. This query returns 1 result
    {
    "query": {
    "term": {
    "sku": "test1"
    }
    }
    }

My question is, how come I can only do an exact match query if the field
(keyword) has no numbers in it? I cant find documents where the sku field
is test1.test

Thanks

--

Interesting and strange. IMHO, it should work. Can you gist a full curl recreation for this case?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 28 déc. 2012 à 21:59, Rick Devinsus rick.devinsus@gmail.com a écrit :

  1. I have a mapping set up for a field called "sku". It is configured as not_analyzed such that I can do exact matches on it

     						.startObject("sku")
     							.field("index", "not_analyzed")
     							.field("type", "string")									
     						.endObject()
    
  2. The database contains a document where sku=test1.test and one where sku=testx.test

  3. This query returns 0 results
    {
    "query": {
    "term": {
    "sku": "test1.test"
    }
    }
    }

  4. This query returns 1 result
    {
    "query": {
    "term": {
    "sku": "testx.test"
    }
    }
    }

  5. This query returns 1 result
    {
    "query": {
    "term": {
    "sku": "test1"
    }
    }
    }

My question is, how come I can only do an exact match query if the field (keyword) has no numbers in it? I cant find documents where the sku field is test1.test

Thanks

--

--

Thanks David. I found my problem, there was more than one field in my
mapping which was done using Jackson via the java API. I was missing
an .endObject() call which meant the JSON generated was incorrect. The
interesting thing is that the mapping was successful for all fields above
the JSON error.

On Friday, December 28, 2012 3:59:41 PM UTC-5, Rick Devinsus wrote:

  1. I have a mapping set up for a field called "sku". It is configured as
    not_analyzed such that I can do exact matches on it

.startObject("sku")
.field("index", "not_analyzed")
.field("type", "string")
.endObject()

  1. The database contains a document where sku=test1.test and one where
    sku=testx.test

  2. This query returns 0 results
    {
    "query": {
    "term": {
    "sku": "test1.test"
    }
    }
    }

  3. This query returns 1 result
    {
    "query": {
    "term": {
    "sku": "testx.test"
    }
    }
    }

  4. This query returns 1 result
    {
    "query": {
    "term": {
    "sku": "test1"
    }
    }
    }

My question is, how come I can only do an exact match query if the field
(keyword) has no numbers in it? I cant find documents where the sku field
is test1.test

Thanks

--