Thanks!
Let's start simple: searching a substring in a single field. Even that was not straightforward...
What took me some time to figure out is that wildcard
search doesn't like Caps, which is not explicit in the doc... Shouldn't that be documented?
For instance
DELETE index
PUT index/_doc/1
{
"full_name": "Service de cardiologie"
}
GET index/_search
{
"query": {
"wildcard": {
"full_name": "Ser*"
}
}
}
gives
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 0,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
}
}
but without the capital "S", it works:
GET index/_search
{
"query": {
"wildcard": {
"full_name": "ser*"
}
}
}
gives a match:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "index",
"_type" : "_doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"full_name" : "Service de cardiologie"
}
}
]
}
}
This behavior is not intuitive, because the match
query does not care about the case:
GET index/_search
{
"query": {
"match": {
"full_name": "Service"
}
}
}
GET index/_search
{
"query": {
"match": {
"full_name": "service"
}
}
}
GET index/_search
{
"query": {
"match": {
"full_name": "SERVICE"
}
}
}
all output the same result (a match).