Hello,
I use this simple process to test elasticsearch on nested field:
- curl -X PUT http://localhost:9200/library
- curl -X POST http://localhost:9200/library/french/_mapping -d '{"french": {"_all" : {"enabled" : true}, "properties": {"title":{"type":"string"},"cast":{"type":"nested","properties":{"firstname":{"type":"string"},"lastname":{"type":"string"}}}}}}'
- curl -X POST http://localhost:9200/library/french/2 -d '{"doc":{"cast":[{"firstname":"John","lastname":"Bob"},{"firstname":"Bob","lastname":"John"}],"title":"The movie Two"}}'
Then i search my document with:
curl -X GET http://localhost:9200/library/french/_search?size=10&from=0 -d '{"query":{"filtered":{"query":{"bool":{"must":[{"nested":{"path":"cast","query":{"bool":{"must":[{"match_phrase":{"firstname":"Bob"}},{"match_phrase":{"lastname":"John"}}]}}}}]}},"filter":{"not":{"regexp":{"_data":".*"}}}}}}'
It returns an empty hits ???
If i add a 4th step to update my data:
4. curl -X POST http://localhost:9200/library/french/2/_update -d '{"doc":{"cast":[{"firstname":"John","lastname":"Bob"},{"firstname":"Bob","lastname":"John"}],"title":"The movie Two"}}'
I've got my result ???
Does someone known why ?
Thanks