PUT test
{
"mappings":{
"folks":{
"properties":{
"works_at": {
"type": "nested"
}
}
}
}
}
PUT /test/folks/1
{
"type": "lawyer",
"works_at": [
{ "location":"New York"},
{ "location":"Boston"}
]
}
PUT /test/folks/2
{
"type": "lawyer",
"works_at": [
{"location":"Chicago"},
{"location":"Boston"}
]
}
PUT /test/folks/3
{
"type": "writer",
"works_at": [
{"location":"San Francisco"},
{"location":"Boston"}
]
}
Then I search, Zero results:
GET /test/folks/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"works_at.location": "Boston"
}
},
{
"match": {
"type": "lawyer"
}
}
]
}
}
}
If the location
portion is taken off, the search works filtering on the type
:
GET /test/folks/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"type": "lawyer"
}
}
]
}
}
}
results:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 0.2876821,
"hits": [
{
"_index": "test",
"_type": "folks",
"_id": "2",
"_score": 0.2876821,
"_source": {
"type": "lawyer",
"works_at": [
{
"location": "Chicago"
},
{
"location": "Boston"
}
]
}
},
{
"_index": "test",
"_type": "folks",
"_id": "1",
"_score": 0.2876821,
"_source": {
"type": "lawyer",
"works_at": [
{
"location": "New York"
},
{
"location": "Boston"
}
]
}
}
]
}
}
What am I missing in my first multi-field search?