Parly resolved! My problem was that I need to specify the routing. With Parent-Child, routing becomes required.
However, even though i'm able to see my documents again, the "_parent" attribute doesn't seem to show up when I query a doc. Do I need to configure the parent type somehow for it to work? I simply modified the mapping of the child type to include _parent. When querying for the mapping, i see _parent in the result: *curl -XGET http://localhost:9200/myindex/feedback/_mapping <http://localhost:9200/myindex/feedback/_mapping>* *{"feedback":{"_parent":{"type":"content"},"_routing":{"required":true},"properties":{"cid":{"type":"long"},"cmi":{"type":"long"},"cp":{"type":"long"},"ct":{"type":"long"},"cwn":{"type":"long"},"dur":{"type":"long"},"fee":{"type":"long"},"ia":{"type":"long"},"ito":{"type":"long"},"mir":{"type":"long"},"mvd":{"type":"long"},"mvt":{"type":"long"},"n":{"type":"string"},"own":{"type":"long"},"pdt":{"type":"long"},"sav":{"type":"string"},"td":{"type":"long"}}}}* Thanks! On Monday, April 21, 2014 11:59:07 PM UTC-4, echin1999 wrote: > > Hi. I am having trouble trying to set the parent attribute for a child > document and was wondering if someone could suggest to me what i'm doing > wrong. > > I have a type called "feedback" which I want to assign a parent attribute > - i want "feedback" to be a child of "content" - so i do the following: > > > *curl -XPUT http://localhost:9200/myindex/feedback/_mapping > <http://localhost:9200/myindex/feedback/_mapping> -d '* > > *{* > > *"feedback" : {* > > * "_parent" : {* > > * "type" : "content"* > > * }* > > * }* > > *}*' > > > My java code to insert a document of type "feedback" look like this: > > *IndexResponse response = _client.prepareIndex(INDEX, TYPE_FEEDBACK, > feedback.getFeedbackId()).setParent(""+feedback.getContentId()).setSource(feedbackJSON.toString()) > > .execute().actionGet();* > > I got back the response fine - and the response had the correct index, > type, and id. > > However, If i try to fetch what i just inserted: > > *curl -XGET http://localhost:9200/myindex/feedback/${1}?pretty=true > <http://localhost:9200/myindex/feedback/$%7B1%7D?pretty=true>* > > I get nothing: > > *{* > > * "_index" : "myindex",* > > * "_type" : "feedback",* > > * "_id" : "3860",* > > * "exists" : false* > > *}* > > > If I examine the mapping, I *think* it looks ok: > > *curl -XGET http://localhost:9200/myindex/feedback/_mapping > <http://localhost:9200/myindex/feedback/_mapping>* > > > *{"feedback":{"_parent":{"type":"content"},"_routing":{"required":true},"properties":{"cid":{"type":"long"},"cmi":{"type":"long"},"cp":{"type":"long"},"ct":{"type":"long"},"cwn":{"type":"long"},"dur":{"type":"long"},"fee":{"type":"long"},"ia":{"type":"long"},"ito":{"type":"long"},"mir":{"type":"long"},"mvd":{"type":"long"},"mvt":{"type":"long"},"n":{"type":"string"},"own":{"type":"long"},"pdt":{"type":"long"},"sav":{"type":"string"},"td":{"type":"long"}}}}* > > > If just search for all id's for that type, I do see the entry: > > *curl http://localhost:9200/myindex/feedback/_search?pretty=true > <http://localhost:9200/myindex/feedback/_search?pretty=true> -d '* > > *{ * > > * "query" : { * > > * "match_all" : {} * > > * },* > > * "fields": []* > > *}* > > *'* > > *{* > > * "took" : 13,* > > * "timed_out" : false,* > > * "_shards" : {* > > * "total" : 5,* > > * "successful" : 5,* > > * "failed" : 0* > > * },* > > * "hits" : {* > > * "total" : 3,* > > * "max_score" : 1.0,* > > * "hits" : [ {* > > * "_index" : "myindex",* > > * "_type" : "feedback",* > > * "_id" : "1_3858",* > > * "_score" : 1.0* > > * }, {* > > * "_index" : "myindex",* > > * "_type" : "feedback",* > > * "_id" : "1_3859",* > > * "_score" : 1.0* > > * }, {* > > * "_index" : "myindex",* > > * "_type" : "feedback",* > > * "_id" : "3860",* > > * "_score" : 1.0* > > * } ]* > > * }* > > *}* > > > Could someone tell me what I could be missing? This is version 0.90 > > Many thanks, > Ed > > -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/58fa7370-9d52-4ce0-ab45-6c60716965e3%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
