Sorry if this is a duplicate (I tried to search), or if this is a stupid question. New to post questions.
I am trying to execute parent child relationships and queries in ElasticSearch with the following:
#!/bin/bash curl -XDELETE 'http://localhost:9200/test/' echo curl -XPUT 'http://localhost:9200/test/' -d '{ "settings" : { "index" : { "number_of_shards" : 1 } } }' echo curl -XPUT localhost:9200/test/_mapping/nelement -d '{ "nelement" : { "_id" : { "path" : "nid", "store" : true, "index" : "not_analyzed"}, "_parent" : { "type" : "nelement"}, "properties" : { "name" : { "type" : "string", "index" : "not_analyzed" }, "nid": { "type" : "string", "copy_to" : "_id" } } } }' echo #curl -s -XPOST localhost:9200/_bulk --data-binary @test_data.json test_data.json is as follows: {"index":{"_index":"test","_type":"element", "_parent":"abc"} {"nid":"1a","name":"parent1"} {"index":{"_index":"test","_type":"element", "_parent":"1a"} {"nid":"2b","name":"child1"} {"index":{"_index":"test","_type":"element", "_parent":"2b"} {"nid":"2c","name":"child2"} curl -XGET 'localhost:9200/test/nelement/_search?pretty=true' -d '{ "query": { "has_child": { "child_type": "nelement", "query": { "match": { "nid": "2c" } } } } }' echo echo curl -XGET 'localhost:9200/test/nelement/_search?pretty=true' -d '{ "query": { "has_parent": { "type": "nelement", "query": { "term": { "nid": "2b" } } } } }'
For some reason, my searches do not return any results. I confirmed that the objects are indexed ....
source share