Exact match not working

I am having issues getting an exact match to work.
I am trying instructs here .

My test case is to have a single index with a single type with a single field which is not analyzed.
I add a record into it and attempt to use a filtered query with a single term match within it.
Yet i get no record back.

Test scripts here:-

printf "\nDelete the index to start from scratch\n";
curl -XDELETE 'http://192.168.134.179:9200/testnames2'
printf "\nCreate the index with a single type, and one field which is not_analyzed\n";
curl -XPOST http://192.168.134.179:9200/testnames2/test -d '{
    "settings" : {
        "number_of_shards" : 1
    },
    "mappings" : {
        "hrname" : {
            "_source" : { "enabled" : true },
            "properties" : {
                "raw_Lookup" : { "type" : "string", "index" : "not_analyzed" }
            }
        }
    }
}'
printf "\nAdd one record into the index of the right type\n";
curl -XPUT 'http://192.168.134.179:9200/testnames2/hrname/1' -d '{
    "raw_Lookup" : "Simon Taylor"
}'
printf "\nAttempt to get the field back using a filtered query using one term with the exact text i inputted\n";
curl -XGET 'http://192.168.134.179:9200/testnames2/_search/?pretty=true' -d '
{
      "query" : {
         "filtered" : {
            "filter" : {
               "term" : {
                  "raw_Lookup" : "Simon Taylor"
               }
            }
         }
      }
}
'
printf "\n";

Output of which is:-

Delete the index to start from scratch
{"acknowledged":true}
Create the index with a single type, and one field which is not_analyzed
{"_index":"testnames2","_type":"test","_id":"AVFKQxwER0bg8LfMuJ_8","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}
Add one record into the index of the right type
{"_index":"testnames2","_type":"hrname","_id":"1","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}
Attempt to get the field back using a filtered query using one term with the exact text i inputted
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : [ ]
  }
}


I must be doing something simple wrong but i cant see it.

Try

 {
   "query": {
     "term": {
       "raw_Lookup": "Simon Taylor" 
     }
   }
 }

Same results:-


curl -XGET 'http://192.168.134.179:9200/testnames2/_search/?pretty=true' -d '
{
      "query" : {
               "term" : {
                  "raw_Lookup" : "Simon Taylor"
                }
        }
}
'

Now just using Query Term RawLookup
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : [ ]
  }
}
Output of analyze{
  "tokens" : [ {
    "token" : "simon",
    "start_offset" : 1,
    "end_offset" : 6,
    "type" : "<ALPHANUM>",
    "position" : 0
  }, {
    "token" : "taylor",
    "start_offset" : 7,
    "end_offset" : 13,
    "type" : "<ALPHANUM>",
    "position" : 1
  } ]
}


Shouldnt the output of analyze show that the not_analyzed field is not broken into tokens?

Probably because you did not refresh the index just after indexing the doc.

script now looks like this:-

printf "\nDelete the index to start from scratch\n";
curl -XDELETE 'http://192.168.134.179:9200/testnames2'
printf "\nCreate the index with a single type, and one field which is not_analyzed\n";
curl -XPOST http://192.168.134.179:9200/testnames2/test -d '{
    "settings" : {
        "number_of_shards" : 1
    },
    "mappings" : {
        "hrname" : {
            "_source" : { "enabled" : true },
            "properties" : {
                "raw_Lookup" : { "type" : "string", "index" : "not_analyzed" }
            }
        }
    }
}'
printf "\nAdd one record into the index of the right type\n";
curl -XPUT 'http://192.168.134.179:9200/testnames2/hrname/1' -d '{
    "raw_Lookup" : "Simon Taylor"
}'
printf "\nRefresh index\n";
curl -XPOST 'http://192.168.134.179:9200/testnames2/_refresh'

printf "\nAttempt to get the field back using a filtered query using one term with the exact text i inputted\n";
curl -XGET 'http://192.168.134.179:9200/testnames2/_search/?pretty=true' -d '
{
      "query" : {
         "filtered" : {
            "filter" : {
               "term" : {
                  "raw_Lookup" : "Simon Taylor"
               }
            }
         }
      }
}
'
printf "Now just using Query Term RawLookup\n";
curl -XGET 'http://192.168.134.179:9200/testnames2/_search/?pretty=true' -d '
{
      "query" : {
               "term" : {
                  "raw_Lookup" : "Simon Taylor"
                }
        }
}
'
printf "Output of analyze"
curl -XGET http://192.168.134.179:9200/testnames2/_analyze?pretty=1,field=raw_Lookup -d'
Simon Taylor'

output looks like:-

elete the index to start from scratch
{"acknowledged":true}
Create the index with a single type, and one field which is not_analyzed
{"_index":"testnames2","_type":"test","_id":"AVFKeAndR0bg8LfMuKAG","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}
Add one record into the index of the right type
{"_index":"testnames2","_type":"hrname","_id":"1","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}
Refresh index
{"_shards":{"total":10,"successful":5,"failed":0}}
Attempt to get the field back using a filtered query using one term with the exact text i inputted
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : [ ]
  }
}
Now just using Query Term RawLookup
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : [ ]
  }
}
Output of analyze{
  "tokens" : [ {
    "token" : "simon",
    "start_offset" : 1,
    "end_offset" : 6,
    "type" : "<ALPHANUM>",
    "position" : 0
  }, {
    "token" : "taylor",
    "start_offset" : 7,
    "end_offset" : 13,
    "type" : "<ALPHANUM>",
    "position" : 1
  } ]
}

still not working

Your POST is to the wrong resource. You need to POST to your index (i.e. testnames2). Your type hrname and its mapping was never create. Notice the type field of the response.

Awesome that was it.
I knew i had been staring at the screen so long as to miss the obvious!
Thank you!