No success to create parent - child relation


(Roy E.) #1

Hi folks,

I've been trying to create a simple parent - child relation between
different search types and finally gave up. I'll be happy if you guys
give me a hand on this;

I have 2 types of search documents, simply "package" and "module" as
in programming. Let's talk on the most famous web framework "Django"
package in Python. First, the mappings:

curl -XGET localhost:9200/pydoc/package/_mapping

{"package":{"_source":{"compress":true},"_id":
{"path":"package_name"},"properties":{"summary":{"store":"yes","boost":
1.2,"type":"string"},"keywords":
{"index_name":"tag","store":"yes","boost":
1.4,"type":"string"},"description":{"boost":
0.8,"type":"string"},"package_name":{"store":"yes","boost":
1.8,"type":"string"},"downloads":
{"store":"yes","type":"integer"},"version":
{"index":"not_analyzed","store":"yes","type":"string"}}}}

curl -XGET localhost:9200/pydoc/module/_mapping

{"module":{"_source":{"compress":true},"_routing":
{"required":true},"properties":{"source_code":
{"path":"full","type":"attachment","fields":{"source_code":
{"type":"string"},"author":{"type":"string"},"title":
{"type":"string"},"keywords":{"type":"string"},"date":
{"format":"dateOptionalTime","type":"date"},"content_type":
{"type":"string"}}},"file_path":
{"store":"yes","type":"string"},"import_name":{"store":"yes","boost":
1.8,"type":"string"}},"_parent":{"type":"package"}}}

As we can see, _parent is mapping to "package" type. Than, let's put
our package:

curl -XPUT localhost:9200/pydoc/package/Django -d '{"description":

null, "package_name": "Django", "downloads": 83193, "summary": "A high-
level Python Web framework that encourages rapid development and
clean, pragmatic design.", "version": "1.3.1", "keywords": []}'

{"ok":true,"_index":"pydoc","_type":"package","_id":"Django","_version":
1}

Now, the problematic process, putting the module that has Django
package as parent:

curl -XPUT localhost:9200/pydoc/module/mytest?parent=Django -d

'{ "import_name" : "django.mytest.etc", "file_path" : "/path/to/
module.py", "source_code" : { "content": "" } }'

{"ok":true,"_index":"pydoc","_type":"module","_id":"mytest","_version":
1}

Right, show me the module document we have just put:

curl -XGET localhost:9200/pydoc/module/mytest

{"_index":"pydoc","_type":"module","_id":"mytest","exists":false}

Exist false? Weird. What if we search?

curl -XGET localhost:9200/pydoc/module/_search?

q=import_name:django.mytest.etc

{"took":2,"timed_out":false,"_shards":{"total":5,"successful":
5,"failed":0},"hits":{"total":1,"max_score":1.75,"hits":
[{"_index":"pydoc","_type":"module","_id":"mytest","_score":1.75,
"_source" : { "import_name" : "django.mytest.etc", "file_path" : "/
path/to/module.py", "source_code" : { "content": "" } }}]}}

No parent, no parent, no parent at all...

The funny thing when I _search in opposite direction with has_child
query:

curl -XGET localhost:9200/pydoc/package/_search -d '{"query" : {

        "has_child": {
                "type": "module",
                "query": {
                  "term": {
                      "import_name" : "django.mytest.etc"
                  }
                }
             }
        }
    }'

gives me the expected result:
{"took":1,"timed_out":false,"_shards":{"total":5,"successful":
5,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":
[{"_index":"pydoc","_type":"package","_id":"Django","_score":1.0,
"_source" : {"description": null, "package_name": "Django",
"downloads": 83193, "summary": "A high-level Python Web framework that
encourages rapid development and clean, pragmatic design.", "version":
"1.3.1", "keywords": []}}]}}

I don't understand. How can I get the parent docs from modules?

Cheers.


(Shay Banon) #2

Answers below:

On Wed, Dec 14, 2011 at 9:26 AM, Roy E. kirpit@gmail.com wrote:

Hi folks,

I've been trying to create a simple parent - child relation between
different search types and finally gave up. I'll be happy if you guys
give me a hand on this;

I have 2 types of search documents, simply "package" and "module" as
in programming. Let's talk on the most famous web framework "Django"
package in Python. First, the mappings:

curl -XGET localhost:9200/pydoc/package/_mapping

{"package":{"_source":{"compress":true},"_id":
{"path":"package_name"},"properties":{"summary":{"store":"yes","boost":
1.2,"type":"string"},"keywords":
{"index_name":"tag","store":"yes","boost":
1.4,"type":"string"},"description":{"boost":
0.8,"type":"string"},"package_name":{"store":"yes","boost":
1.8,"type":"string"},"downloads":
{"store":"yes","type":"integer"},"version":
{"index":"not_analyzed","store":"yes","type":"string"}}}}

curl -XGET localhost:9200/pydoc/module/_mapping

{"module":{"_source":{"compress":true},"_routing":
{"required":true},"properties":{"source_code":
{"path":"full","type":"attachment","fields":{"source_code":
{"type":"string"},"author":{"type":"string"},"title":
{"type":"string"},"keywords":{"type":"string"},"date":
{"format":"dateOptionalTime","type":"date"},"content_type":
{"type":"string"}}},"file_path":
{"store":"yes","type":"string"},"import_name":{"store":"yes","boost":
1.8,"type":"string"}},"_parent":{"type":"package"}}}

As we can see, _parent is mapping to "package" type. Than, let's put
our package:

curl -XPUT localhost:9200/pydoc/package/Django -d '{"description":

null, "package_name": "Django", "downloads": 83193, "summary": "A high-
level Python Web framework that encourages rapid development and
clean, pragmatic design.", "version": "1.3.1", "keywords": []}'

{"ok":true,"_index":"pydoc","_type":"package","_id":"Django","_version":
1}

Now, the problematic process, putting the module that has Django
package as parent:

curl -XPUT localhost:9200/pydoc/module/mytest?parent=Django -d

'{ "import_name" : "django.mytest.etc", "file_path" : "/path/to/
module.py", "source_code" : { "content": "" } }'

{"ok":true,"_index":"pydoc","_type":"module","_id":"mytest","_version":
1}

Right, show me the module document we have just put:

curl -XGET localhost:9200/pydoc/module/mytest

{"_index":"pydoc","_type":"module","_id":"mytest","exists":false}

Exist false? Weird.

children are mapped to the same shard as the parent (using the parent as
the routing value). You need to provide the parent value to the get API as
the routing value. i.e.: ?routing=Django

What if we search?

curl -XGET localhost:9200/pydoc/module/_search?

q=import_name:django.mytest.etc

{"took":2,"timed_out":false,"_shards":{"total":5,"successful":
5,"failed":0},"hits":{"total":1,"max_score":1.75,"hits":
[{"_index":"pydoc","_type":"module","_id":"mytest","_score":1.75,
"_source" : { "import_name" : "django.mytest.etc", "file_path" : "/
path/to/module.py", "source_code" : { "content": "" } }}]}}

No parent, no parent, no parent at all...

You need to explicitly ask for the _parent field to get it back.

The funny thing when I _search in opposite direction with has_child
query:

curl -XGET localhost:9200/pydoc/package/_search -d '{"query" : {

        "has_child": {
                "type": "module",
                "query": {
                  "term": {
                      "import_name" : "django.mytest.etc"
                  }
                }
             }
        }
    }'

gives me the expected result:
{"took":1,"timed_out":false,"_shards":{"total":5,"successful":
5,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":
[{"_index":"pydoc","_type":"package","_id":"Django","_score":1.0,
"_source" : {"description": null, "package_name": "Django",
"downloads": 83193, "summary": "A high-level Python Web framework that
encourages rapid development and clean, pragmatic design.", "version":
"1.3.1", "keywords": []}}]}}

I don't understand. How can I get the parent docs from modules?

Cheers.


(Roy E.) #3

I got it,

So you are saying that i have to do another query for each children if
i want to display the results based on parents? Because _parent only
gives the id of the parent.. Don't you think that we should be able to
access like;

"result.meta.parent.package_name" or "result.meta.parent.version"?

cheers.

On Dec 17, 2:34 am, Shay Banon kim...@gmail.com wrote:

Answers below:

On Wed, Dec 14, 2011 at 9:26 AM, Roy E. kir...@gmail.com wrote:

Hi folks,

I've been trying to create a simple parent - child relation between
different search types and finally gave up. I'll be happy if you guys
give me a hand on this;

I have 2 types of search documents, simply "package" and "module" as
in programming. Let's talk on the most famous web framework "Django"
package in Python. First, the mappings:

curl -XGET localhost:9200/pydoc/package/_mapping

{"package":{"_source":{"compress":true},"_id":
{"path":"package_name"},"properties":{"summary":{"store":"yes","boost":
1.2,"type":"string"},"keywords":
{"index_name":"tag","store":"yes","boost":
1.4,"type":"string"},"description":{"boost":
0.8,"type":"string"},"package_name":{"store":"yes","boost":
1.8,"type":"string"},"downloads":
{"store":"yes","type":"integer"},"version":
{"index":"not_analyzed","store":"yes","type":"string"}}}}

curl -XGET localhost:9200/pydoc/module/_mapping

{"module":{"_source":{"compress":true},"_routing":
{"required":true},"properties":{"source_code":
{"path":"full","type":"attachment","fields":{"source_code":
{"type":"string"},"author":{"type":"string"},"title":
{"type":"string"},"keywords":{"type":"string"},"date":
{"format":"dateOptionalTime","type":"date"},"content_type":
{"type":"string"}}},"file_path":
{"store":"yes","type":"string"},"import_name":{"store":"yes","boost":
1.8,"type":"string"}},"_parent":{"type":"package"}}}

As we can see, _parent is mapping to "package" type. Than, let's put
our package:

curl -XPUT localhost:9200/pydoc/package/Django -d '{"description":

null, "package_name": "Django", "downloads": 83193, "summary": "A high-
level Python Web framework that encourages rapid development and
clean, pragmatic design.", "version": "1.3.1", "keywords": []}'

{"ok":true,"_index":"pydoc","_type":"package","_id":"Django","_version":
1}

Now, the problematic process, putting the module that has Django
package as parent:

curl -XPUT localhost:9200/pydoc/module/mytest?parent=Django -d

'{ "import_name" : "django.mytest.etc", "file_path" : "/path/to/
module.py", "source_code" : { "content": "" } }'

{"ok":true,"_index":"pydoc","_type":"module","_id":"mytest","_version":
1}

Right, show me the module document we have just put:

curl -XGET localhost:9200/pydoc/module/mytest

{"_index":"pydoc","_type":"module","_id":"mytest","exists":false}

Exist false? Weird.

children are mapped to the same shard as the parent (using the parent as
the routing value). You need to provide the parent value to the get API as
the routing value. i.e.: ?routing=Django

What if we search?

curl -XGET localhost:9200/pydoc/module/_search?

q=import_name:django.mytest.etc

{"took":2,"timed_out":false,"_shards":{"total":5,"successful":
5,"failed":0},"hits":{"total":1,"max_score":1.75,"hits":
[{"_index":"pydoc","_type":"module","_id":"mytest","_score":1.75,
"_source" : { "import_name" : "django.mytest.etc", "file_path" : "/
path/to/module.py", "source_code" : { "content": "" } }}]}}

No parent, no parent, no parent at all...

You need to explicitly ask for the _parent field to get it back.

The funny thing when I _search in opposite direction with has_child
query:

curl -XGET localhost:9200/pydoc/package/_search -d '{"query" : {

        "has_child": {
                "type": "module",
                "query": {
                  "term": {
                      "import_name" : "django.mytest.etc"
                  }
                }
             }
        }
    }'

gives me the expected result:
{"took":1,"timed_out":false,"_shards":{"total":5,"successful":
5,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":
[{"_index":"pydoc","_type":"package","_id":"Django","_score":1.0,
"_source" : {"description": null, "package_name": "Django",
"downloads": 83193, "summary": "A high-level Python Web framework that
encourages rapid development and clean, pragmatic design.", "version":
"1.3.1", "keywords": []}}]}}

I don't understand. How can I get the parent docs from modules?

Cheers.


(Shay Banon) #4

Yea, it would be nice to be able to access the parent in a script or
something, but its not available now.

On Wed, Dec 21, 2011 at 1:39 PM, Roy E. kirpit@gmail.com wrote:

I got it,

So you are saying that i have to do another query for each children if
i want to display the results based on parents? Because _parent only
gives the id of the parent.. Don't you think that we should be able to
access like;

"result.meta.parent.package_name" or "result.meta.parent.version"?

cheers.

On Dec 17, 2:34 am, Shay Banon kim...@gmail.com wrote:

Answers below:

On Wed, Dec 14, 2011 at 9:26 AM, Roy E. kir...@gmail.com wrote:

Hi folks,

I've been trying to create a simple parent - child relation between
different search types and finally gave up. I'll be happy if you guys
give me a hand on this;

I have 2 types of search documents, simply "package" and "module" as
in programming. Let's talk on the most famous web framework "Django"
package in Python. First, the mappings:

curl -XGET localhost:9200/pydoc/package/_mapping

{"package":{"_source":{"compress":true},"_id":
{"path":"package_name"},"properties":{"summary":{"store":"yes","boost":
1.2,"type":"string"},"keywords":
{"index_name":"tag","store":"yes","boost":
1.4,"type":"string"},"description":{"boost":
0.8,"type":"string"},"package_name":{"store":"yes","boost":
1.8,"type":"string"},"downloads":
{"store":"yes","type":"integer"},"version":
{"index":"not_analyzed","store":"yes","type":"string"}}}}

curl -XGET localhost:9200/pydoc/module/_mapping

{"module":{"_source":{"compress":true},"_routing":
{"required":true},"properties":{"source_code":
{"path":"full","type":"attachment","fields":{"source_code":
{"type":"string"},"author":{"type":"string"},"title":
{"type":"string"},"keywords":{"type":"string"},"date":
{"format":"dateOptionalTime","type":"date"},"content_type":
{"type":"string"}}},"file_path":
{"store":"yes","type":"string"},"import_name":{"store":"yes","boost":
1.8,"type":"string"}},"_parent":{"type":"package"}}}

As we can see, _parent is mapping to "package" type. Than, let's put
our package:

curl -XPUT localhost:9200/pydoc/package/Django -d '{"description":

null, "package_name": "Django", "downloads": 83193, "summary": "A high-
level Python Web framework that encourages rapid development and
clean, pragmatic design.", "version": "1.3.1", "keywords": []}'

{"ok":true,"_index":"pydoc","_type":"package","_id":"Django","_version":

1}

Now, the problematic process, putting the module that has Django
package as parent:

curl -XPUT localhost:9200/pydoc/module/mytest?parent=Django -d

'{ "import_name" : "django.mytest.etc", "file_path" : "/path/to/
module.py", "source_code" : { "content": "" } }'

{"ok":true,"_index":"pydoc","_type":"module","_id":"mytest","_version":
1}

Right, show me the module document we have just put:

curl -XGET localhost:9200/pydoc/module/mytest

{"_index":"pydoc","_type":"module","_id":"mytest","exists":false}

Exist false? Weird.

children are mapped to the same shard as the parent (using the parent as
the routing value). You need to provide the parent value to the get API
as
the routing value. i.e.: ?routing=Django

What if we search?

curl -XGET localhost:9200/pydoc/module/_search?

q=import_name:django.mytest.etc

{"took":2,"timed_out":false,"_shards":{"total":5,"successful":
5,"failed":0},"hits":{"total":1,"max_score":1.75,"hits":
[{"_index":"pydoc","_type":"module","_id":"mytest","_score":1.75,
"_source" : { "import_name" : "django.mytest.etc", "file_path" : "/
path/to/module.py", "source_code" : { "content": "" } }}]}}

No parent, no parent, no parent at all...

You need to explicitly ask for the _parent field to get it back.

The funny thing when I _search in opposite direction with has_child
query:

curl -XGET localhost:9200/pydoc/package/_search -d '{"query" : {

        "has_child": {
                "type": "module",
                "query": {
                  "term": {
                      "import_name" : "django.mytest.etc"
                  }
                }
             }
        }
    }'

gives me the expected result:
{"took":1,"timed_out":false,"_shards":{"total":5,"successful":
5,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":
[{"_index":"pydoc","_type":"package","_id":"Django","_score":1.0,
"_source" : {"description": null, "package_name": "Django",
"downloads": 83193, "summary": "A high-level Python Web framework that
encourages rapid development and clean, pragmatic design.", "version":
"1.3.1", "keywords": []}}]}}

I don't understand. How can I get the parent docs from modules?

Cheers.


(Roy E.) #5

thanks a lot kimchy and all the elasticsearch community for letting us
to have such a great search platform. and i also want to thank to the
pyes community for their support on python driver.

as of now, pythonistas are able to "search" for any python package, on
elasticsearch of course. give it a try;
http://pydoc.net/s?q=elastic+search

cheers,
roy.

On Dec 22 2011, 11:51 am, Shay Banon kim...@gmail.com wrote:

Yea, it would be nice to be able to access the parent in a script or
something, but its not available now.

On Wed, Dec 21, 2011 at 1:39 PM, Roy E. kir...@gmail.com wrote:

I got it,

So you are saying that i have to do another query for each children if
i want to display the results based on parents? Because _parent only
gives the id of the parent.. Don't you think that we should be able to
access like;

"result.meta.parent.package_name" or "result.meta.parent.version"?

cheers.

On Dec 17, 2:34 am, Shay Banon kim...@gmail.com wrote:

Answers below:

On Wed, Dec 14, 2011 at 9:26 AM, Roy E. kir...@gmail.com wrote:

Hi folks,

I've been trying to create a simple parent - child relation between
different search types and finally gave up. I'll be happy if you guys
give me a hand on this;

I have 2 types of search documents, simply "package" and "module" as
in programming. Let's talk on the most famous web framework "Django"
package in Python. First, the mappings:

curl -XGET localhost:9200/pydoc/package/_mapping

{"package":{"_source":{"compress":true},"_id":
{"path":"package_name"},"properties":{"summary":{"store":"yes","boost":
1.2,"type":"string"},"keywords":
{"index_name":"tag","store":"yes","boost":
1.4,"type":"string"},"description":{"boost":
0.8,"type":"string"},"package_name":{"store":"yes","boost":
1.8,"type":"string"},"downloads":
{"store":"yes","type":"integer"},"version":
{"index":"not_analyzed","store":"yes","type":"string"}}}}

curl -XGET localhost:9200/pydoc/module/_mapping

{"module":{"_source":{"compress":true},"_routing":
{"required":true},"properties":{"source_code":
{"path":"full","type":"attachment","fields":{"source_code":
{"type":"string"},"author":{"type":"string"},"title":
{"type":"string"},"keywords":{"type":"string"},"date":
{"format":"dateOptionalTime","type":"date"},"content_type":
{"type":"string"}}},"file_path":
{"store":"yes","type":"string"},"import_name":{"store":"yes","boost":
1.8,"type":"string"}},"_parent":{"type":"package"}}}

As we can see, _parent is mapping to "package" type. Than, let's put
our package:

curl -XPUT localhost:9200/pydoc/package/Django -d '{"description":

null, "package_name": "Django", "downloads": 83193, "summary": "A high-
level Python Web framework that encourages rapid development and
clean, pragmatic design.", "version": "1.3.1", "keywords": []}'

{"ok":true,"_index":"pydoc","_type":"package","_id":"Django","_version":

1}

Now, the problematic process, putting the module that has Django
package as parent:

curl -XPUT localhost:9200/pydoc/module/mytest?parent=Django -d

'{ "import_name" : "django.mytest.etc", "file_path" : "/path/to/
module.py", "source_code" : { "content": "" } }'

{"ok":true,"_index":"pydoc","_type":"module","_id":"mytest","_version":
1}

Right, show me the module document we have just put:

curl -XGET localhost:9200/pydoc/module/mytest

{"_index":"pydoc","_type":"module","_id":"mytest","exists":false}

Exist false? Weird.

children are mapped to the same shard as the parent (using the parent as
the routing value). You need to provide the parent value to the get API
as
the routing value. i.e.: ?routing=Django

What if we search?

curl -XGET localhost:9200/pydoc/module/_search?

q=import_name:django.mytest.etc

{"took":2,"timed_out":false,"_shards":{"total":5,"successful":
5,"failed":0},"hits":{"total":1,"max_score":1.75,"hits":
[{"_index":"pydoc","_type":"module","_id":"mytest","_score":1.75,
"_source" : { "import_name" : "django.mytest.etc", "file_path" : "/
path/to/module.py", "source_code" : { "content": "" } }}]}}

No parent, no parent, no parent at all...

You need to explicitly ask for the _parent field to get it back.

The funny thing when I _search in opposite direction with has_child
query:

curl -XGET localhost:9200/pydoc/package/_search -d '{"query" : {

        "has_child": {
                "type": "module",
                "query": {
                  "term": {
                      "import_name" : "django.mytest.etc"
                  }
                }
             }
        }
    }'

gives me the expected result:
{"took":1,"timed_out":false,"_shards":{"total":5,"successful":
5,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":
[{"_index":"pydoc","_type":"package","_id":"Django","_score":1.0,
"_source" : {"description": null, "package_name": "Django",
"downloads": 83193, "summary": "A high-level Python Web framework that
encourages rapid development and clean, pragmatic design.", "version":
"1.3.1", "keywords": []}}]}}

I don't understand. How can I get the parent docs from modules?

Cheers.


(Shay Banon) #6

Great job!

On Sun, Jan 1, 2012 at 10:47 PM, Roy E. kirpit@gmail.com wrote:

thanks a lot kimchy and all the elasticsearch community for letting us
to have such a great search platform. and i also want to thank to the
pyes community for their support on python driver.

as of now, pythonistas are able to "search" for any python package, on
elasticsearch of course. give it a try;
http://pydoc.net/s?q=elastic+search

cheers,
roy.

On Dec 22 2011, 11:51 am, Shay Banon kim...@gmail.com wrote:

Yea, it would be nice to be able to access the parent in a script or
something, but its not available now.

On Wed, Dec 21, 2011 at 1:39 PM, Roy E. kir...@gmail.com wrote:

I got it,

So you are saying that i have to do another query for each children if
i want to display the results based on parents? Because _parent only
gives the id of the parent.. Don't you think that we should be able to
access like;

"result.meta.parent.package_name" or "result.meta.parent.version"?

cheers.

On Dec 17, 2:34 am, Shay Banon kim...@gmail.com wrote:

Answers below:

On Wed, Dec 14, 2011 at 9:26 AM, Roy E. kir...@gmail.com wrote:

Hi folks,

I've been trying to create a simple parent - child relation between
different search types and finally gave up. I'll be happy if you
guys

give me a hand on this;

I have 2 types of search documents, simply "package" and "module"
as

in programming. Let's talk on the most famous web framework
"Django"

package in Python. First, the mappings:

curl -XGET localhost:9200/pydoc/package/_mapping

{"package":{"_source":{"compress":true},"_id":

{"path":"package_name"},"properties":{"summary":{"store":"yes","boost":

1.2,"type":"string"},"keywords":
{"index_name":"tag","store":"yes","boost":
1.4,"type":"string"},"description":{"boost":
0.8,"type":"string"},"package_name":{"store":"yes","boost":
1.8,"type":"string"},"downloads":
{"store":"yes","type":"integer"},"version":
{"index":"not_analyzed","store":"yes","type":"string"}}}}

curl -XGET localhost:9200/pydoc/module/_mapping

{"module":{"_source":{"compress":true},"_routing":
{"required":true},"properties":{"source_code":
{"path":"full","type":"attachment","fields":{"source_code":
{"type":"string"},"author":{"type":"string"},"title":
{"type":"string"},"keywords":{"type":"string"},"date":
{"format":"dateOptionalTime","type":"date"},"content_type":
{"type":"string"}}},"file_path":

{"store":"yes","type":"string"},"import_name":{"store":"yes","boost":

1.8,"type":"string"}},"_parent":{"type":"package"}}}

As we can see, _parent is mapping to "package" type. Than, let's
put

our package:

curl -XPUT localhost:9200/pydoc/package/Django -d

'{"description":

null, "package_name": "Django", "downloads": 83193, "summary": "A
high-

level Python Web framework that encourages rapid development and
clean, pragmatic design.", "version": "1.3.1", "keywords": []}'

{"ok":true,"_index":"pydoc","_type":"package","_id":"Django","_version":

1}

Now, the problematic process, putting the module that has Django
package as parent:

curl -XPUT localhost:9200/pydoc/module/mytest?parent=Django -d

'{ "import_name" : "django.mytest.etc", "file_path" : "/path/to/
module.py", "source_code" : { "content": "" } }'

{"ok":true,"_index":"pydoc","_type":"module","_id":"mytest","_version":

1}

Right, show me the module document we have just put:

curl -XGET localhost:9200/pydoc/module/mytest

{"_index":"pydoc","_type":"module","_id":"mytest","exists":false}

Exist false? Weird.

children are mapped to the same shard as the parent (using the
parent as

the routing value). You need to provide the parent value to the get
API

as

the routing value. i.e.: ?routing=Django

What if we search?

curl -XGET localhost:9200/pydoc/module/_search?

q=import_name:django.mytest.etc

{"took":2,"timed_out":false,"_shards":{"total":5,"successful":
5,"failed":0},"hits":{"total":1,"max_score":1.75,"hits":
[{"_index":"pydoc","_type":"module","_id":"mytest","_score":1.75,
"_source" : { "import_name" : "django.mytest.etc", "file_path" : "/
path/to/module.py", "source_code" : { "content": "" } }}]}}

No parent, no parent, no parent at all...

You need to explicitly ask for the _parent field to get it back.

The funny thing when I _search in opposite direction with has_child
query:

curl -XGET localhost:9200/pydoc/package/_search -d '{"query" : {

        "has_child": {
                "type": "module",
                "query": {
                  "term": {
                      "import_name" : "django.mytest.etc"
                  }
                }
             }
        }
    }'

gives me the expected result:
{"took":1,"timed_out":false,"_shards":{"total":5,"successful":
5,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":
[{"_index":"pydoc","_type":"package","_id":"Django","_score":1.0,
"_source" : {"description": null, "package_name": "Django",
"downloads": 83193, "summary": "A high-level Python Web framework
that

encourages rapid development and clean, pragmatic design.",
"version":

"1.3.1", "keywords": []}}]}}

I don't understand. How can I get the parent docs from modules?

Cheers.


(system) #7