Parent Mapping missing


(Frifri) #1

Hello everybody,

I use the following two mappings in a parent child deployment:

curl -X PUT "localhost:9200/parchildev/attachment/_mapping" -d '{
"attachment" : {
"properties" : {
"file" : {
"type" : "attachment",
"fields" : {
"title" : { "store" : "yes" },
"file" : { "term_vector":"with_positions_offsets", "store":"yes" }
}
}
}
}
}'

curl -X PUT 'localhost:9200/parchildev/comment/_mapping' -d '{
"comment" : {
"_parent" : {
"type" : "attachment"
},
"properties" : {
"user" : {"type" : "string"},
"message" : {"type" : "string", "null_value" : "na"},
"car": {"type" : "string"}
}
}
}'

Then I index a pdf into attachment which works fine

Now I put the following to the child mapping:

curl -XPUT 'localhost:9200/parchildev/comment/1?parent='
-d '{
"user":"esuser",
"message":"amplifier",
"car":"audi a4"
}'

If I now query, the inner query returns an error message
curl "${host}/_search?pretty=true" -d '{
"fields" : ["title"],
"query": {
"bool": {
"must": [
{
"has_child": {
"type": "comment",
"query": {
"query_string" : {
"query" : "amplifier"
}
}
}
}
]
}
},

"highlight" : {
"fields" : {
"file" : {}
}
}
}'

{
"took" : 5,
"timed_out" : false,
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 1,
"failures" : [ {
"index" : "test",
"shard" : 0,
"status" : 400,
"reason" : "SearchParseException[[test][0]: from[-1],size[-1]: Parse
Failure [Failed to parse source [{\n"fields" : ["title"],\n "query":
{\n "bool": {\n "must": [\n {\n "has_child":
{\n "type": "comment",\n "query":
{\n"query_string" : {\n"query" : "amplifier"\n}\n
}\n }\n }\n ]\n }\n },\n\n"highlight" :
{\n"fields" : {\n"file" : {}\n}\n}\n}]]]; nested:
QueryParsingException[[test] [has_child] Type [comment] does not have
parent mapping]; "
} ]
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}

How to define the child mapping? I didn't find any working minimal
examples...

I used the following two sites
http://www.elasticsearch.org/guide/reference/mapping/parent-field.html and
http://www.elasticsearch.org/guide/reference/mapping/


(Frifri) #2

No clue? Looks like there's just a simple error in the declaration of the
mapping.


(Shay Banon) #3

You seem to search across all indices. See the exception, it comes from the
"test" index, where it probably does not have the relevant mapping
definition.

On Fri, Sep 2, 2011 at 2:02 PM, Frifri henning.frieder@googlemail.comwrote:

No clue? Looks like there's just a simple error in the declaration of the
mapping.


(Frifri) #4

Thx, my bad... embarassing...


(Shay Banon) #5

Not at all!

On Tue, Sep 6, 2011 at 11:33 AM, Frifri henning.frieder@googlemail.comwrote:

Thx, my bad... embarassing...


(Frifri) #6

Another question on this lovely saturday afternoon:

I use the mappings from the initial post.

Lets say I have 2 parents A,B (type attachment) with only one child *a *linked
to A.

  • A contains something, but *not *"entry 1"
  • a contains "entry 1"
  • B contains "entry 1"

I need a query structure which returns A (as parent of a) and* B* for
the term "entry 1".

I tried like this, but it returns only *A *as parent of a:

curl "localhost:9200/parchildev/_search?pretty=true" -d '{
"fields" : ["title"],
"query" : {
"has_child": {
"type": "comment",
"query": {
"query_string" : {
"query" : "entry 1"
}
}
}
},
"highlight" : {
"fields" : {
"file": {}
}
}
}'

I experimented with a filter, but of course, this one returns a and Binstead of
*A *and B.
curl "localhost:9200/parchildev/_search?pretty=true" -d '{
"fields" : ["title"],
"filter": {
"or": [
{
"has_child": {
"type": "comment",
"query": {
"query_string" : {
"query" : "entry 1"
}
}
}
}
,
{
"query": {
"query_string" : {
"query" : "entry 1"
}
}
}
]
}
}'

I think, I need narrow the search pattern of the second search term to the
attachment mapping. I tried to insert "type": "attachment" like

{
"query": {
"type": "attachment",
"query_string" : {
"query" : "entry 1"
}
}
}

but I don't quite well understand the terminology... Sry for this basic
question.

Thx in advance for your support.


(Frifri) #7

No one has got a clue?


(Frifri) #8

The following query seems to work, but highlighting isn't working at all (so
i removed it from the gist).

Has someone an idea how to verify if this query does what I want?


(system) #9