I have what I believe is a use case that many using elastic search would like to have. Here is my template
PUT _template/test
{
"template" : "test*",
"settings" : {
"number_of_shards" : 5,
"number_of_replicas" : 1
},
"mappings" : {
"test": {
"properties": {
"name": {
"type": "string",
"index": "analyzed"
},
"description": {
"type": "string",
"index": "analyzed",
"analyzer":"english",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
Now I'm going to put a single record in the index
POST /test/test
{
"name":"test-1",
"description":"on the first day of christmas my true love gave to me a partridge in a pear tree"
}
Now imagine I have a million of these records. What I want to do is that if I search for on the on the description field I would like nothing to come back because those are common words that the english analyzer should take care of. However if I do a search for exact text "on the" then I would like documents to return that match the exact text.
My question to the elastic community is how do I allow for this and what should the query look like? I added the .raw field for description but no matter what my query string is I can't get the exact text to return any results.
{ "query": { "term": { "description.raw": "on the" } }}- Richa{ "took": 1, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 0, "max_score": null, "hits": [] } }- Casey Johnson