Hi all,
First and foremost: I searched the archives and the only post I found which is similar to my issue was this http://elasticsearch-users.115913.n3.nabble.com/Search-query-issue-using-quot-term-quot-and-spaces-td1020831.html
I'm a new user of ElasticSearch and am currently trying to wrap my head around being able to search for moth exact and partial matches.
Partial matches I can do
The problem I have is exact matches; take for example the following (very simple) records:
{ "name" : "Chris Gedrim" }
{ "name" : "Peter Gedrim" }
Both of which live in the 'test' index with a type of 'people'.
I run the following query (for partial matching):
{
"query" : {
"query_string" : {
"query" : "name:Gedrim"
}
}
}
Which returns:
"hits" : {
"total" : 2,
"max_score" : 0.19178301,
"hits" : [ {
"_index" : "test",
"_type" : "chrisgedrim",
"_id" : "t-eRmndRQ3uwKI4c01v2Aw",
"_score" : 0.19178301, "_source" : {name:"Peter Gedrim"}
}, {
"_index" : "test",
"_type" : "chrisgedrim",
"_id" : "vbWG0Py0SdCSGnW2kfeaZg",
"_score" : 0.19178301, "_source" : {name:"Chris Gedrim"}
} ]
}
All of which is fine.
I then run the following (for an exact match):
{
"query" : {
"term" : {
"name" : "Chris Gedrim"
}
}
}
Which returns:
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
From the previously linked-to post I think I should be creating a multi-field mapping thus:
{
"people" : {
"properties" : {
"name" : {
"type" : "multi_field",
"fields" : {
"name" : {"type" : "string", "index" : "analyzed"},
"untouched" : {"type" : "string", "index" : "not_analyzed"}
}
}
}
}
}
Is this correct? If so is there any way of setting all strings to use this mapping?
Also: would the term query above work correctly with this new mapping, or does it need modifying to use the 'untouched' field?
Cheers,
Chris