Embedded query

Is it possible to perform the query as embedded type and retrieves it as
nested type? I'll explain. I have the following mapping.

{
"page" : {
"properties" : {
"number" : {"type" : "integer", "store" : "yes", "index":"analyzed"},
"file_name" : {"type" : "string", "store" : "yes", "index":"no"},
"line" : {
"type" : "object",
"properties" : {
"number" : {"type" : "integer", "store" : "yes", "index":"not_analyzed"},
"text" : {"type" : "string", "store" : "no", "index":"analyzed"}
}
}
}
}

}

The data.

{
"page" : {
"id" : "1",
"number" : 1,
"file_name" : "page1.jpg",
"line" : [ {
"number" : 1,
"text" : "Informally, an object’s state is its data, stored in state
variables such as instance"
} ,
{
"number" : 2,
"text" : "or static fields. An object’s state may include fields from
other, dependent objects"
},
{
"number" : 3,
"text" : "a HashMap’s state is partially stored in the HashMap object
itself, but also in many"
},
{
"number" : 4,
"text" : "Map.Entry objects. An object’s state encompasses any data
that can affect its"
}]
}
}

I run the query above :

{
"query": {
"bool" : {
"must" : [{"term": {"text": "Informally," } } ,
{"term": {"text": "state" } } ]
}
}
}

The document "page" with id 1, will be returned from my query, because the
word "informally" and "state" are in the same document page (line 1 and
line 3). It's perfect, embedded objects work this way. And my objective is
really get the mandatory words within the document page. If the page
document was a nested type, query would not work in the desired manner.

{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.23977767,
"hits": [
{
"_index": "docman",
"_type": "page",
"_id": "1",
"_score": 0.23977767,
"_source": {
"page": {
"id": "1",
"number": 1,
"file_name": "page1.jpg",
"line": [
{
"number": 1,
"text": "Informally, an object’s state is its data,
stored in state variables such as instance"
},
{
"number": 2,
"text": "or static fields. An object’s state may
include fields from other, dependent objects"
},
{
"number": 3,
"text": "a HashMap’s state is partially stored in
the HashMap object itself, but also in many"
},
{
"number": 4,
"text": "Map.Entry objects. An object’s state
encompasses any data that can affect its"
}
]
}
}
}
]
}
}

in my scenario, the problem is, I do not like that the result of my query
to bring the lines 2 and 3, since they do not have the words searched.
That's why at first I said "perform the query as embedded type and
retrieves it as nested type." Is there any way to do this?

--
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/b5978770-41ae-48a8-b093-9d32e9211a16%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.