# Is there a way to overcome "cross object" search matches in Elastic Search when using nested types?

**URL:** <https://discuss.elastic.co/t/is-there-a-way-to-overcome-cross-object-search-matches-in-elastic-search-when-using-nested-types/11960>\
**Category:** Elasticsearch\
**Created:** [May 14, 2013, 4:15pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-overcome-cross-object-search-matches-in-elastic-search-when-using-nested-types/11960 "2013-05-14T16:15:36Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![rakesh\_rakshit](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@rakesh\_rakshit](https://discuss.elastic.co/u/rakesh_rakshit)\
**Post date:** [May 14, 2013, 4:15pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-overcome-cross-object-search-matches-in-elastic-search-when-using-nested-types/11960/1 "2013-05-14T16:15:36Z")

</div>

Hi all,

I have one of the column which is nested and has structure similar to this:

{ "obj1" : [{ "name" : "blue", "count" : 4 }, { "name" : "green", "count" : 6 }] }

Now if I want to search an object with name= blue and count=6 , ideally this should not get a match but  
this happens to find this document as a match.

So I want to get rid of this situation and want that it should not return a match for the above scenario.

How can I overcome this situation?

Can anyone suggest a solution or an alternate way to implement this?

Thanks in advance.

Regards,

Rakesh Kumar Rakshit

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [May 14, 2013, 4:52pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-overcome-cross-object-search-matches-in-elastic-search-when-using-nested-types/11960/2 "2013-05-14T16:52:32Z")

</div>

Hi Rakesh,

I think you should set obj1 as type Nested:

> **[Elastic — The Search AI Company](https://www.elastic.co)**
>
> Power insights and outcomes with The Elastic Search AI Platform. See into your data and find answers that matter with enterprise solutions designed to help you accelerate time to insight. Try Elastic ...

Then, you would need to use nested  
queries[http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/)and/or  
filters[http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/)to  
find those documents.

## Best regards, Radu

[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit \<[ihavethepotential@gmail.com](mailto:ihavethepotential@gmail.com)

> wrote:

> Hi all,
> 
> I have one of the column which is nested and has structure similar to this:
> 
> { "obj1" : [{ "name" : "blue", "count" : 4 }, { "name" : "green", "count" : 6 }] }
> 
> Now if I want to search an object with name= blue and count=6 , ideally this should not get a match but  
> this happens to find this document as a match.
> 
> So I want to get rid of this situation and want that it should not return a match for the above scenario.
> 
> How can I overcome this situation?
> 
> Can anyone suggest a solution or an alternate way to implement this?
> 
> Thanks in advance.
> 
> Regards,
> 
> Rakesh Kumar Rakshit
> 
> --  
> 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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![rakesh\_rakshit](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@rakesh\_rakshit](https://discuss.elastic.co/u/rakesh_rakshit)\
**Post date:** [May 15, 2013, 6:38am UTC](https://discuss.elastic.co/t/is-there-a-way-to-overcome-cross-object-search-matches-in-elastic-search-when-using-nested-types/11960/3 "2013-05-15T06:38:34Z")

</div>

Hi Radu,

Thanks for your response.

The usecase is we have a column which is of type nested and can have any  
attribute added dynamically which we dont know about.

So our mapping and sample record looks like this:

Mapping:  
{

```
"ipdr" : {
"_source" : {
    "excludes" : ["column1","column2"],
        "includes" : ["mynestedcolumn.*"]
    },
    "properties" : {
        "column1" : {"type" : "string"},
        "column2" : {"type" : "string"},
        "mynestedcolumn" : {
            "type" : "nested"
        }
    }
}

```

}

Record:

{  
"column1": "someValue",  
"column2":"anotherValue",  
"mynestedcolumn":  
{  
"serialno" : "7634786",  
"count": 10,  
"users":[  
{  
"id":"user1",  
"comments":[  
{  
"comment":"comment1"  
},  
{  
"comment":"comment2"  
},  
{  
"comment":"comment3"  
}

```
                           ]
                },
                {
                    "id":"user2",
                    "comments":[
                            {
                                "comment":"dgjkdgjdg"
                            },
                            {
                                "comment":"Hows this?"
                            },
                            {
                                "comment":"No comments."
                            }

                           ]
                }
            ]
    }

```

}

Now I want to search a document with id="user1" and comment="Hows this?"  
and ideally this should not return a document.

Thanks and Regards,  
Rakesh Kumar Rakshit

On Tuesday, May 14, 2013 10:22:32 PM UTC+5:30, Radu Gheorghe wrote:

> Hi Rakesh,
> 
> I think you should set obj1 as type Nested:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/nested-type/)
> 
> Then, you would need to use nested queries[http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/)and/or  
> filters[http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/)to find those documents.
> 
> ## Best regards, Radu
> 
> [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> 
> On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit \<[ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi all,
> > 
> > I have one of the column which is nested and has structure similar to  
> > this:
> > 
> > { "obj1" : [{ "name" : "blue", "count" : 4 }, { "name" : "green", "count" : 6 }] }
> > 
> > Now if I want to search an object with name= blue and count=6 , ideally this should not get a match but  
> > this happens to find this document as a match.
> > 
> > So I want to get rid of this situation and want that it should not return a match for the above scenario.
> > 
> > How can I overcome this situation?
> > 
> > Can anyone suggest a solution or an alternate way to implement this?
> > 
> > Thanks in advance.
> > 
> > Regards,
> > 
> > Rakesh Kumar Rakshit
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![aash\_dhariya](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@aash\_dhariya](https://discuss.elastic.co/u/aash_dhariya)\
**Post date:** [May 15, 2013, 6:44am UTC](https://discuss.elastic.co/t/is-there-a-way-to-overcome-cross-object-search-matches-in-elastic-search-when-using-nested-types/11960/4 "2013-05-15T06:44:06Z")

</div>

Can you post the elasticsearch query that you made to retrieve the relevant  
documents?

On Wed, May 15, 2013 at 12:08 PM, rakesh rakshit \<  
[ihavethepotential@gmail.com](mailto:ihavethepotential@gmail.com)\> wrote:

> Hi Radu,
> 
> Thanks for your response.
> 
> The usecase is we have a column which is of type nested and can have any  
> attribute added dynamically which we dont know about.
> 
> So our mapping and sample record looks like this:
> 
> Mapping:  
> {
> 
> ```
> "ipdr" : {
> "_source" : {
> "excludes" : ["column1","column2"],
> "includes" : ["mynestedcolumn.*"]
> },
> "properties" : {
> "column1" : {"type" : "string"},
> "column2" : {"type" : "string"},
> "mynestedcolumn" : {
> "type" : "nested"
> }
> }
> }
> 
> ```
> 
> }
> 
> Record:
> 
> {  
> "column1": "someValue",  
> "column2":"anotherValue",  
> "mynestedcolumn":  
> {  
> "serialno" : "7634786",  
> "count": 10,  
> "users":[  
> {  
> "id":"user1",  
> "comments":[  
> {  
> "comment":"comment1"  
> },  
> {  
> "comment":"comment2"  
> },  
> {  
> "comment":"comment3"  
> }
> 
> ```
> ]
> },
> {
> "id":"user2",
> "comments":[
> {
> "comment":"dgjkdgjdg"
> },
> {
> "comment":"Hows this?"
> },
> {
> "comment":"No comments."
> }
> 
> ]
> }
> ]
> }
> 
> ```
> 
> }
> 
> Now I want to search a document with id="user1" and comment="Hows this?"  
> and ideally this should not return a document.
> 
> Thanks and Regards,  
> Rakesh Kumar Rakshit
> 
> On Tuesday, May 14, 2013 10:22:32 PM UTC+5:30, Radu Gheorghe wrote:
> 
> > Hi Rakesh,
> > 
> > I think you should set obj1 as type Nested:  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/ **guide/reference/mapping/** nested-type/)[http://www.elasticsearch.org/guide/reference/mapping/nested-type/](http://www.elasticsearch.org/guide/reference/mapping/nested-type/)
> > 
> > Then, you would need to use nested queries[http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/)and/or  
> > filters[http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/)to find those documents.
> > 
> > ## Best regards, Radu
> > 
> > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > 
> > On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)wrote:
> > 
> > > Hi all,
> > > 
> > > I have one of the column which is nested and has structure similar to  
> > > this:
> > > 
> > > { "obj1" : [{ "name" : "blue", "count" : 4 }, { "name" : "green", "count" : 6 }] }
> > > 
> > > Now if I want to search an object with name= blue and count=6 , ideally this should not get a match but  
> > > this happens to find this document as a match.
> > > 
> > > So I want to get rid of this situation and want that it should not return a match for the above scenario.
> > > 
> > > How can I overcome this situation?
> > > 
> > > Can anyone suggest a solution or an alternate way to implement this?
> > > 
> > > Thanks in advance.
> > > 
> > > Regards,
> > > 
> > > Rakesh Kumar Rakshit
> > > 
> > > --  
> > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > 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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Thanks,  
Aash

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [May 15, 2013, 7:44am UTC](https://discuss.elastic.co/t/is-there-a-way-to-overcome-cross-object-search-matches-in-elastic-search-when-using-nested-types/11960/5 "2013-05-15T07:44:12Z")

</div>

Hi Rakesh,

Can you post a curl recreation of your mapping and document (and maybe also  
your query that doesn't work as expected) in gist or some similar tool?

I've tried to test by copying what's in your Email and I'm finding it hard  
to debug the JSON formatting errors.

One thing that I find wrong so far is that you probably want your nested  
objects to be in mynestedcolumn.users, not mynestedcolumn alone.

Best regards,  
Radu

On Wed, May 15, 2013 at 9:38 AM, rakesh rakshit \<[ihavethepotential@gmail.com](mailto:ihavethepotential@gmail.com)

> wrote:

> Hi Radu,
> 
> Thanks for your response.
> 
> The usecase is we have a column which is of type nested and can have any  
> attribute added dynamically which we dont know about.
> 
> So our mapping and sample record looks like this:
> 
> Mapping:  
> {
> 
> ```
> "ipdr" : {
> "_source" : {
> "excludes" : ["column1","column2"],
> "includes" : ["mynestedcolumn.*"]
> },
> "properties" : {
> "column1" : {"type" : "string"},
> "column2" : {"type" : "string"},
> "mynestedcolumn" : {
> "type" : "nested"
> }
> }
> }
> 
> ```
> 
> }
> 
> Record:
> 
> {  
> "column1": "someValue",  
> "column2":"anotherValue",  
> "mynestedcolumn":  
> {  
> "serialno" : "7634786",  
> "count": 10,  
> "users":[  
> {  
> "id":"user1",  
> "comments":[  
> {  
> "comment":"comment1"  
> },  
> {  
> "comment":"comment2"  
> },  
> {  
> "comment":"comment3"  
> }
> 
> ```
> ]
> },
> {
> "id":"user2",
> "comments":[
> {
> "comment":"dgjkdgjdg"
> },
> {
> "comment":"Hows this?"
> },
> {
> "comment":"No comments."
> }
> 
> ]
> }
> ]
> }
> 
> ```
> 
> }
> 
> Now I want to search a document with id="user1" and comment="Hows this?"  
> and ideally this should not return a document.
> 
> Thanks and Regards,  
> Rakesh Kumar Rakshit
> 
> On Tuesday, May 14, 2013 10:22:32 PM UTC+5:30, Radu Gheorghe wrote:
> 
> > Hi Rakesh,
> > 
> > I think you should set obj1 as type Nested:  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/ **guide/reference/mapping/** nested-type/)[http://www.elasticsearch.org/guide/reference/mapping/nested-type/](http://www.elasticsearch.org/guide/reference/mapping/nested-type/)
> > 
> > Then, you would need to use nested queries[http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/)and/or  
> > filters[http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/)to find those documents.
> > 
> > ## Best regards, Radu
> > 
> > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > 
> > On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)wrote:
> > 
> > > Hi all,
> > > 
> > > I have one of the column which is nested and has structure similar to  
> > > this:
> > > 
> > > { "obj1" : [{ "name" : "blue", "count" : 4 }, { "name" : "green", "count" : 6 }] }
> > > 
> > > Now if I want to search an object with name= blue and count=6 , ideally this should not get a match but  
> > > this happens to find this document as a match.
> > > 
> > > So I want to get rid of this situation and want that it should not return a match for the above scenario.
> > > 
> > > How can I overcome this situation?
> > > 
> > > Can anyone suggest a solution or an alternate way to implement this?
> > > 
> > > Thanks in advance.
> > > 
> > > Regards,
> > > 
> > > Rakesh Kumar Rakshit
> > > 
> > > --  
> > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > 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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![rakesh\_rakshit](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@rakesh\_rakshit](https://discuss.elastic.co/u/rakesh_rakshit)\
**Post date:** [May 15, 2013, 11:41am UTC](https://discuss.elastic.co/t/is-there-a-way-to-overcome-cross-object-search-matches-in-elastic-search-when-using-nested-types/11960/6 "2013-05-15T11:41:25Z")

</div>

Hi all,

Here is the query I am firing:

{  
"and":[  
{"nested":  
{  
"path":"mynestedcolumn",  
"query":  
{  
"term":  
{"comment":"dgjkdgjdg"  
}  
}  
}  
},  
{"nested":  
{  
"path":"mynestedcolumn",  
"query":  
{  
"term":  
{"id":"user1"  
}  
}  
}  
}  
]  
}

Regards,  
Rakesh

On Wednesday, May 15, 2013 1:14:12 PM UTC+5:30, Radu Gheorghe wrote:

> Hi Rakesh,
> 
> Can you post a curl recreation of your mapping and document (and maybe  
> also your query that doesn't work as expected) in gist or some similar tool?
> 
> I've tried to test by copying what's in your Email and I'm finding it hard  
> to debug the JSON formatting errors.
> 
> One thing that I find wrong so far is that you probably want your nested  
> objects to be in mynestedcolumn.users, not mynestedcolumn alone.
> 
> Best regards,  
> Radu
> 
> On Wed, May 15, 2013 at 9:38 AM, rakesh rakshit \<[ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi Radu,
> > 
> > Thanks for your response.
> > 
> > The usecase is we have a column which is of type nested and can have any  
> > attribute added dynamically which we dont know about.
> > 
> > So our mapping and sample record looks like this:
> > 
> > Mapping:  
> > {
> > 
> > ```
> > "ipdr" : {
> > "_source" : {
> > "excludes" : ["column1","column2"],
> > "includes" : ["mynestedcolumn.*"]
> > },
> > "properties" : {
> > "column1" : {"type" : "string"},
> > "column2" : {"type" : "string"},
> > "mynestedcolumn" : {
> > "type" : "nested"
> > }
> > }
> > }
> > 
> > ```
> > 
> > }
> > 
> > Record:
> > 
> > {  
> > "column1": "someValue",  
> > "column2":"anotherValue",  
> > "mynestedcolumn":  
> > {  
> > "serialno" : "7634786",  
> > "count": 10,  
> > "users":[  
> > {  
> > "id":"user1",  
> > "comments":[  
> > {  
> > "comment":"comment1"  
> > },  
> > {  
> > "comment":"comment2"  
> > },  
> > {  
> > "comment":"comment3"  
> > }
> > 
> > ```
> > ]
> > },
> > {
> > "id":"user2",
> > "comments":[
> > {
> > "comment":"dgjkdgjdg"
> > },
> > {
> > "comment":"Hows this?"
> > },
> > {
> > "comment":"No comments."
> > }
> > 
> > ]
> > }
> > ]
> > }
> > 
> > ```
> > 
> > }
> > 
> > Now I want to search a document with id="user1" and comment="Hows this?"  
> > and ideally this should not return a document.
> > 
> > Thanks and Regards,  
> > Rakesh Kumar Rakshit
> > 
> > On Tuesday, May 14, 2013 10:22:32 PM UTC+5:30, Radu Gheorghe wrote:
> > 
> > > Hi Rakesh,
> > > 
> > > I think you should set obj1 as type Nested:  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/ **guide/reference/mapping/** nested-type/)[http://www.elasticsearch.org/guide/reference/mapping/nested-type/](http://www.elasticsearch.org/guide/reference/mapping/nested-type/)
> > > 
> > > Then, you would need to use nested queries[http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/)and/or  
> > > filters[http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/)to find those documents.
> > > 
> > > ## Best regards, Radu
> > > 
> > > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > > 
> > > On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)wrote:
> > > 
> > > > Hi all,
> > > > 
> > > > I have one of the column which is nested and has structure similar to  
> > > > this:
> > > > 
> > > > { "obj1" : [{ "name" : "blue", "count" : 4 }, { "name" : "green", "count" : 6 }] }
> > > > 
> > > > Now if I want to search an object with name= blue and count=6 , ideally this should not get a match but  
> > > > this happens to find this document as a match.
> > > > 
> > > > So I want to get rid of this situation and want that it should not return a match for the above scenario.
> > > > 
> > > > How can I overcome this situation?
> > > > 
> > > > Can anyone suggest a solution or an alternate way to implement this?
> > > > 
> > > > Thanks in advance.
> > > > 
> > > > Regards,
> > > > 
> > > > Rakesh Kumar Rakshit
> > > > 
> > > > --  
> > > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > > 
> > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > .
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [May 15, 2013, 11:45am UTC](https://discuss.elastic.co/t/is-there-a-way-to-overcome-cross-object-search-matches-in-elastic-search-when-using-nested-types/11960/7 "2013-05-15T11:45:20Z")

</div>

Hi Rakesh,

Try changing the mapping as I said before, with mynestedcolumn.users as the  
nested type.

Then, when you do the query, put the and filter within the nested filter  
and not the other way around. Also, when you refer to fields in the term  
filters, use the full path (eg: mynestedcolumn.users.id).

Best regards,  
Radu

On Wed, May 15, 2013 at 2:41 PM, rakesh rakshit \<[ihavethepotential@gmail.com](mailto:ihavethepotential@gmail.com)

> wrote:

> Hi all,
> 
> Here is the query I am firing:
> 
> {  
> "and":[  
> {"nested":  
> {  
> "path":"mynestedcolumn",  
> "query":  
> {  
> "term":  
> {"comment":"dgjkdgjdg"  
> }  
> }  
> }  
> },  
> {"nested":  
> {  
> "path":"mynestedcolumn",  
> "query":  
> {  
> "term":  
> {"id":"user1"  
> }  
> }  
> }  
> }  
> ]  
> }
> 
> Regards,  
> Rakesh
> 
> On Wednesday, May 15, 2013 1:14:12 PM UTC+5:30, Radu Gheorghe wrote:
> 
> > Hi Rakesh,
> > 
> > Can you post a curl recreation of your mapping and document (and maybe  
> > also your query that doesn't work as expected) in gist or some similar tool?
> > 
> > I've tried to test by copying what's in your Email and I'm finding it  
> > hard to debug the JSON formatting errors.
> > 
> > One thing that I find wrong so far is that you probably want your nested  
> > objects to be in mynestedcolumn.users, not mynestedcolumn alone.
> > 
> > Best regards,  
> > Radu
> > 
> > On Wed, May 15, 2013 at 9:38 AM, rakesh rakshit [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)wrote:
> > 
> > > Hi Radu,
> > > 
> > > Thanks for your response.
> > > 
> > > The usecase is we have a column which is of type nested and can have any  
> > > attribute added dynamically which we dont know about.
> > > 
> > > So our mapping and sample record looks like this:
> > > 
> > > Mapping:  
> > > {
> > > 
> > > ```
> > > "ipdr" : {
> > > "_source" : {
> > > "excludes" : ["column1","column2"],
> > > "includes" : ["mynestedcolumn.*"]
> > > },
> > > "properties" : {
> > > "column1" : {"type" : "string"},
> > > "column2" : {"type" : "string"},
> > > "mynestedcolumn" : {
> > > "type" : "nested"
> > > }
> > > }
> > > }
> > > 
> > > ```
> > > 
> > > }
> > > 
> > > Record:
> > > 
> > > {  
> > > "column1": "someValue",  
> > > "column2":"anotherValue",  
> > > "mynestedcolumn":  
> > > {  
> > > "serialno" : "7634786",  
> > > "count": 10,  
> > > "users":[  
> > > {  
> > > "id":"user1",  
> > > "comments":[  
> > > {  
> > > "comment":"comment1"  
> > > },  
> > > {  
> > > "comment":"comment2"  
> > > },  
> > > {  
> > > "comment":"comment3"  
> > > }
> > > 
> > > ```
> > > ]
> > > },
> > > {
> > > "id":"user2",
> > > "comments":[
> > > {
> > > "comment":"dgjkdgjdg"
> > > },
> > > {
> > > "comment":"Hows this?"
> > > },
> > > {
> > > "comment":"No comments."
> > > }
> > > 
> > > ]
> > > }
> > > ]
> > > }
> > > 
> > > ```
> > > 
> > > }
> > > 
> > > Now I want to search a document with id="user1" and comment="Hows this?"  
> > > and ideally this should not return a document.
> > > 
> > > Thanks and Regards,  
> > > Rakesh Kumar Rakshit
> > > 
> > > On Tuesday, May 14, 2013 10:22:32 PM UTC+5:30, Radu Gheorghe wrote:
> > > 
> > > > Hi Rakesh,
> > > > 
> > > > I think you should set obj1 as type Nested:  
> > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/ **g** uide/reference/mapping/**nested-)\*\*  
> > > > type/[http://www.elasticsearch.org/guide/reference/mapping/nested-type/](http://www.elasticsearch.org/guide/reference/mapping/nested-type/)
> > > > 
> > > > Then, you would need to use nested queries[http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/)and/or  
> > > > filters[http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/)to find those documents.
> > > > 
> > > > ## Best regards, Radu
> > > > 
> > > > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > > > 
> > > > On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit \<[ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)
> > > > 
> > > > > wrote:
> > > > 
> > > > > Hi all,
> > > > > 
> > > > > I have one of the column which is nested and has structure similar to  
> > > > > this:
> > > > > 
> > > > > { "obj1" : [{ "name" : "blue", "count" : 4 }, { "name" : "green", "count" : 6 }] }
> > > > > 
> > > > > Now if I want to search an object with name= blue and count=6 , ideally this should not get a match but  
> > > > > this happens to find this document as a match.
> > > > > 
> > > > > So I want to get rid of this situation and want that it should not return a match for the above scenario.
> > > > > 
> > > > > How can I overcome this situation?
> > > > > 
> > > > > Can anyone suggest a solution or an alternate way to implement this?
> > > > > 
> > > > > Thanks in advance.
> > > > > 
> > > > > Regards,
> > > > > 
> > > > > Rakesh Kumar Rakshit
> > > > > 
> > > > > --  
> > > > > 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 elasticsearc...@\*\*googlegroups.\*\*com.
> > > > > 
> > > > > For more options, visit [https://groups.google.com/\*\*grou\*\*ps/opt\_out](https://groups.google.com/ **grou** ps/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > .
> > > > 
> > > > --  
> > > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).  
> > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > .
> > 
> > --  
> > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> 
> --  
> 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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![rakesh\_rakshit](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@rakesh\_rakshit](https://discuss.elastic.co/u/rakesh_rakshit)\
**Post date:** [May 16, 2013, 6:46am UTC](https://discuss.elastic.co/t/is-there-a-way-to-overcome-cross-object-search-matches-in-elastic-search-when-using-nested-types/11960/8 "2013-05-16T06:46:06Z")

</div>

Hi Radu,

I changed the mapping to this:

{  
"ipdr" : {  
"properties" : {  
"c0" : {"type" : "string"},  
"c1" : {"type" : "string"},  
"mynestedcolumn" : { "type" : "nested"},  
"mynestedcolumn.users" : { "type" : "nested"},  
"mynestedcolumn.users.comments" : { "type" : "nested"},  
}  
}  
}

And my search query to this:

{  
"nested" : {  
"filter" : {  
"and" : {  
"filters" : [ {  
"term" : {  
"mynestedcolumn.users.comments.comment" : "dgjkdgjdg"  
}  
}, {  
"term" : {  
"mynestedcolumn.users.id" : "user1"  
}  
} ]  
}  
},  
"path" : "mynestedcolumn"  
}  
}

Still it is returning me the document which it should not.

Please tell me where I am going wrong and suggest if changes required.

Regards,  
Rakesh

On Wednesday, May 15, 2013 5:15:20 PM UTC+5:30, Radu Gheorghe wrote:

> Hi Rakesh,
> 
> Try changing the mapping as I said before, with mynestedcolumn.users as  
> the nested type.
> 
> Then, when you do the query, put the and filter within the nested filter  
> and not the other way around. Also, when you refer to fields in the term  
> filters, use the full path (eg: mynestedcolumn.users.id).
> 
> Best regards,  
> Radu
> 
> On Wed, May 15, 2013 at 2:41 PM, rakesh rakshit \<[ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi all,
> > 
> > Here is the query I am firing:
> > 
> > {  
> > "and":[  
> > {"nested":  
> > {  
> > "path":"mynestedcolumn",  
> > "query":  
> > {  
> > "term":  
> > {"comment":"dgjkdgjdg"  
> > }  
> > }  
> > }  
> > },  
> > {"nested":  
> > {  
> > "path":"mynestedcolumn",  
> > "query":  
> > {  
> > "term":  
> > {"id":"user1"  
> > }  
> > }  
> > }  
> > }  
> > ]  
> > }
> > 
> > Regards,  
> > Rakesh
> > 
> > On Wednesday, May 15, 2013 1:14:12 PM UTC+5:30, Radu Gheorghe wrote:
> > 
> > > Hi Rakesh,
> > > 
> > > Can you post a curl recreation of your mapping and document (and maybe  
> > > also your query that doesn't work as expected) in gist or some similar tool?
> > > 
> > > I've tried to test by copying what's in your Email and I'm finding it  
> > > hard to debug the JSON formatting errors.
> > > 
> > > One thing that I find wrong so far is that you probably want your nested  
> > > objects to be in mynestedcolumn.users, not mynestedcolumn alone.
> > > 
> > > Best regards,  
> > > Radu
> > > 
> > > On Wed, May 15, 2013 at 9:38 AM, rakesh rakshit [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)wrote:
> > > 
> > > > Hi Radu,
> > > > 
> > > > Thanks for your response.
> > > > 
> > > > The usecase is we have a column which is of type nested and can have  
> > > > any attribute added dynamically which we dont know about.
> > > > 
> > > > So our mapping and sample record looks like this:
> > > > 
> > > > Mapping:  
> > > > {
> > > > 
> > > > ```
> > > > "ipdr" : {
> > > > "_source" : {
> > > > "excludes" : ["column1","column2"],
> > > > "includes" : ["mynestedcolumn.*"]
> > > > },
> > > > "properties" : {
> > > > "column1" : {"type" : "string"},
> > > > "column2" : {"type" : "string"},
> > > > "mynestedcolumn" : {
> > > > "type" : "nested"
> > > > }
> > > > }
> > > > }
> > > > 
> > > > ```
> > > > 
> > > > }
> > > > 
> > > > Record:
> > > > 
> > > > {  
> > > > "column1": "someValue",  
> > > > "column2":"anotherValue",  
> > > > "mynestedcolumn":  
> > > > {  
> > > > "serialno" : "7634786",  
> > > > "count": 10,  
> > > > "users":[  
> > > > {  
> > > > "id":"user1",  
> > > > "comments":[  
> > > > {  
> > > > "comment":"comment1"  
> > > > },  
> > > > {  
> > > > "comment":"comment2"  
> > > > },  
> > > > {  
> > > > "comment":"comment3"  
> > > > }
> > > > 
> > > > ```
> > > > ]
> > > > },
> > > > {
> > > > "id":"user2",
> > > > "comments":[
> > > > {
> > > > "comment":"dgjkdgjdg"
> > > > },
> > > > {
> > > > "comment":"Hows this?"
> > > > },
> > > > {
> > > > "comment":"No comments."
> > > > }
> > > > 
> > > > ]
> > > > }
> > > > ]
> > > > }
> > > > 
> > > > ```
> > > > 
> > > > }
> > > > 
> > > > Now I want to search a document with id="user1" and comment="Hows  
> > > > this?" and ideally this should not return a document.
> > > > 
> > > > Thanks and Regards,  
> > > > Rakesh Kumar Rakshit
> > > > 
> > > > On Tuesday, May 14, 2013 10:22:32 PM UTC+5:30, Radu Gheorghe wrote:
> > > > 
> > > > > Hi Rakesh,
> > > > > 
> > > > > I think you should set obj1 as type Nested:  
> > > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/ **g** uide/reference/mapping/**nested-)\*\*  
> > > > > type/[http://www.elasticsearch.org/guide/reference/mapping/nested-type/](http://www.elasticsearch.org/guide/reference/mapping/nested-type/)
> > > > > 
> > > > > Then, you would need to use nested queries[http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/)and/or  
> > > > > filters[http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/)to find those documents.
> > > > > 
> > > > > ## Best regards, Radu
> > > > > 
> > > > > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > > > > 
> > > > > On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit \<  
> > > > > [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)\> wrote:
> > > > > 
> > > > > > Hi all,
> > > > > > 
> > > > > > I have one of the column which is nested and has structure similar to  
> > > > > > this:
> > > > > > 
> > > > > > { "obj1" : [{ "name" : "blue", "count" : 4 }, { "name" : "green", "count" : 6 }] }
> > > > > > 
> > > > > > Now if I want to search an object with name= blue and count=6 , ideally this should not get a match but  
> > > > > > this happens to find this document as a match.
> > > > > > 
> > > > > > So I want to get rid of this situation and want that it should not return a match for the above scenario.
> > > > > > 
> > > > > > How can I overcome this situation?
> > > > > > 
> > > > > > Can anyone suggest a solution or an alternate way to implement this?
> > > > > > 
> > > > > > Thanks in advance.
> > > > > > 
> > > > > > Regards,
> > > > > > 
> > > > > > Rakesh Kumar Rakshit
> > > > > > 
> > > > > > --  
> > > > > > 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 elasticsearc...@\*\*googlegroups.\*\*com.
> > > > > > 
> > > > > > For more options, visit [https://groups.google.com/\*\*grou\*\*ps/opt\_out](https://groups.google.com/ **grou** ps/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > > .
> > > > > 
> > > > > --  
> > > > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).  
> > > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > .
> > > 
> > > --  
> > > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [May 16, 2013, 7:07am UTC](https://discuss.elastic.co/t/is-there-a-way-to-overcome-cross-object-search-matches-in-elastic-search-when-using-nested-types/11960/9 "2013-05-16T07:07:17Z")

</div>

Hi Rakesh,

Can you provide a curl recreation [http://www.elasticsearch.org/help/](http://www.elasticsearch.org/help/) of  
the problem? It's hard for me to copy paste from the Email.

Best regards,  
Radu

On Thu, May 16, 2013 at 9:46 AM, rakesh rakshit \<[ihavethepotential@gmail.com](mailto:ihavethepotential@gmail.com)

> wrote:

> Hi Radu,
> 
> I changed the mapping to this:
> 
> {  
> "ipdr" : {  
> "properties" : {  
> "c0" : {"type" : "string"},  
> "c1" : {"type" : "string"},  
> "mynestedcolumn" : { "type" : "nested"},  
> "mynestedcolumn.users" : { "type" : "nested"},  
> "mynestedcolumn.users.comments" : { "type" : "nested"},  
> }  
> }  
> }
> 
> And my search query to this:
> 
> {  
> "nested" : {  
> "filter" : {  
> "and" : {  
> "filters" : [ {  
> "term" : {  
> "mynestedcolumn.users.comments.comment" : "dgjkdgjdg"  
> }  
> }, {  
> "term" : {  
> "mynestedcolumn.users.id" : "user1"  
> }  
> } ]  
> }  
> },  
> "path" : "mynestedcolumn"  
> }  
> }
> 
> Still it is returning me the document which it should not.
> 
> Please tell me where I am going wrong and suggest if changes required.
> 
> Regards,  
> Rakesh
> 
> On Wednesday, May 15, 2013 5:15:20 PM UTC+5:30, Radu Gheorghe wrote:
> 
> > Hi Rakesh,
> > 
> > Try changing the mapping as I said before, with mynestedcolumn.users as  
> > the nested type.
> > 
> > Then, when you do the query, put the and filter within the nested filter  
> > and not the other way around. Also, when you refer to fields in the term  
> > filters, use the full path (eg: mynestedcolumn.users.id).
> > 
> > Best regards,  
> > Radu
> > 
> > On Wed, May 15, 2013 at 2:41 PM, rakesh rakshit [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)wrote:
> > 
> > > Hi all,
> > > 
> > > Here is the query I am firing:
> > > 
> > > {  
> > > "and":[  
> > > {"nested":  
> > > {  
> > > "path":"mynestedcolumn",  
> > > "query":  
> > > {  
> > > "term":  
> > > {"comment":"dgjkdgjdg"  
> > > }  
> > > }  
> > > }  
> > > },  
> > > {"nested":  
> > > {  
> > > "path":"mynestedcolumn",  
> > > "query":  
> > > {  
> > > "term":  
> > > {"id":"user1"  
> > > }  
> > > }  
> > > }  
> > > }  
> > > ]  
> > > }
> > > 
> > > Regards,  
> > > Rakesh
> > > 
> > > On Wednesday, May 15, 2013 1:14:12 PM UTC+5:30, Radu Gheorghe wrote:
> > > 
> > > > Hi Rakesh,
> > > > 
> > > > Can you post a curl recreation of your mapping and document (and maybe  
> > > > also your query that doesn't work as expected) in gist or some similar tool?
> > > > 
> > > > I've tried to test by copying what's in your Email and I'm finding it  
> > > > hard to debug the JSON formatting errors.
> > > > 
> > > > One thing that I find wrong so far is that you probably want your  
> > > > nested objects to be in mynestedcolumn.users, not mynestedcolumn alone.
> > > > 
> > > > Best regards,  
> > > > Radu
> > > > 
> > > > On Wed, May 15, 2013 at 9:38 AM, rakesh rakshit [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)wrote:
> > > > 
> > > > > Hi Radu,
> > > > > 
> > > > > Thanks for your response.
> > > > > 
> > > > > The usecase is we have a column which is of type nested and can have  
> > > > > any attribute added dynamically which we dont know about.
> > > > > 
> > > > > So our mapping and sample record looks like this:
> > > > > 
> > > > > Mapping:  
> > > > > {
> > > > > 
> > > > > ```
> > > > > "ipdr" : {
> > > > > "_source" : {
> > > > > "excludes" : ["column1","column2"],
> > > > > "includes" : ["mynestedcolumn.*"]
> > > > > },
> > > > > "properties" : {
> > > > > "column1" : {"type" : "string"},
> > > > > "column2" : {"type" : "string"},
> > > > > "mynestedcolumn" : {
> > > > > "type" : "nested"
> > > > > }
> > > > > }
> > > > > }
> > > > > 
> > > > > ```
> > > > > 
> > > > > }
> > > > > 
> > > > > Record:
> > > > > 
> > > > > {  
> > > > > "column1": "someValue",  
> > > > > "column2":"anotherValue",  
> > > > > "mynestedcolumn":  
> > > > > {  
> > > > > "serialno" : "7634786",  
> > > > > "count": 10,  
> > > > > "users":[  
> > > > > {  
> > > > > "id":"user1",  
> > > > > "comments":[  
> > > > > {  
> > > > > "comment":"comment1"  
> > > > > },  
> > > > > {  
> > > > > "comment":"comment2"  
> > > > > },  
> > > > > {  
> > > > > "comment":"comment3"  
> > > > > }
> > > > > 
> > > > > ```
> > > > > ]
> > > > > },
> > > > > {
> > > > > "id":"user2",
> > > > > "comments":[
> > > > > {
> > > > > "comment":"dgjkdgjdg"
> > > > > },
> > > > > {
> > > > > "comment":"Hows this?"
> > > > > },
> > > > > {
> > > > > "comment":"No comments."
> > > > > }
> > > > > 
> > > > > ]
> > > > > }
> > > > > ]
> > > > > }
> > > > > 
> > > > > ```
> > > > > 
> > > > > }
> > > > > 
> > > > > Now I want to search a document with id="user1" and comment="Hows  
> > > > > this?" and ideally this should not return a document.
> > > > > 
> > > > > Thanks and Regards,  
> > > > > Rakesh Kumar Rakshit
> > > > > 
> > > > > On Tuesday, May 14, 2013 10:22:32 PM UTC+5:30, Radu Gheorghe wrote:
> > > > > 
> > > > > > Hi Rakesh,
> > > > > > 
> > > > > > I think you should set obj1 as type Nested:  
> > > > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/ **g**** uide/reference/mapping/**nested-)\*  
> > > > > > \*\*\*type/[http://www.elasticsearch.org/guide/reference/mapping/nested-type/](http://www.elasticsearch.org/guide/reference/mapping/nested-type/)
> > > > > > 
> > > > > > Then, you would need to use nested queries[http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/)and/or  
> > > > > > filters[http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/)to find those documents.
> > > > > > 
> > > > > > ## Best regards, Radu
> > > > > > 
> > > > > > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > > > > > 
> > > > > > On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit \<  
> > > > > > [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)\> wrote:
> > > > > > 
> > > > > > > Hi all,
> > > > > > > 
> > > > > > > I have one of the column which is nested and has structure similar  
> > > > > > > to this:
> > > > > > > 
> > > > > > > { "obj1" : [{ "name" : "blue", "count" : 4 }, { "name" : "green", "count" : 6 }] }
> > > > > > > 
> > > > > > > Now if I want to search an object with name= blue and count=6 , ideally this should not get a match but  
> > > > > > > this happens to find this document as a match.
> > > > > > > 
> > > > > > > So I want to get rid of this situation and want that it should not return a match for the above scenario.
> > > > > > > 
> > > > > > > How can I overcome this situation?
> > > > > > > 
> > > > > > > Can anyone suggest a solution or an alternate way to implement this?
> > > > > > > 
> > > > > > > Thanks in advance.
> > > > > > > 
> > > > > > > Regards,
> > > > > > > 
> > > > > > > Rakesh Kumar Rakshit
> > > > > > > 
> > > > > > > --  
> > > > > > > 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 elasticsearc...@\*\*googlegroups. **c** om.
> > > > > > > 
> > > > > > > For more options, visit [https://groups.google.com/\*\*grou](https://groups.google.com/**grou)\*\*\*\*  
> > > > > > > ps/opt\_out [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > > > > > 
> > > > > > --  
> > > > > > 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 elasticsearc...@\*\*googlegroups.\*\*com.  
> > > > > > For more options, visit [https://groups.google.com/\*\*grou\*\*ps/opt\_out](https://groups.google.com/ **grou** ps/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > > .
> > > > 
> > > > --  
> > > > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > > 
> > > --  
> > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).  
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> 
> --  
> 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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![rakesh\_rakshit](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@rakesh\_rakshit](https://discuss.elastic.co/u/rakesh_rakshit)\
**Post date:** [May 16, 2013, 9:51am UTC](https://discuss.elastic.co/t/is-there-a-way-to-overcome-cross-object-search-matches-in-elastic-search-when-using-nested-types/11960/10 "2013-05-16T09:51:16Z")

</div>

Hi Radu,

I am using the Elastic search java api to fire the query and finding it  
difficult since I created a curl recreation for the same but it is giving  
errors. I am trying it and will provide it as soon as it works.

Regards,  
Rakesh

On Thursday, May 16, 2013 12:37:17 PM UTC+5:30, Radu Gheorghe wrote:

> Hi Rakesh,
> 
> Can you provide a curl recreation [http://www.elasticsearch.org/help/](http://www.elasticsearch.org/help/) of  
> the problem? It's hard for me to copy paste from the Email.
> 
> Best regards,  
> Radu
> 
> On Thu, May 16, 2013 at 9:46 AM, rakesh rakshit \<[ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi Radu,
> > 
> > I changed the mapping to this:
> > 
> > {  
> > "ipdr" : {  
> > "properties" : {  
> > "c0" : {"type" : "string"},  
> > "c1" : {"type" : "string"},  
> > "mynestedcolumn" : { "type" : "nested"},  
> > "mynestedcolumn.users" : { "type" : "nested"},  
> > "mynestedcolumn.users.comments" : { "type" : "nested"},  
> > }  
> > }  
> > }
> > 
> > And my search query to this:
> > 
> > {  
> > "nested" : {  
> > "filter" : {  
> > "and" : {  
> > "filters" : [ {  
> > "term" : {  
> > "mynestedcolumn.users.comments.comment" : "dgjkdgjdg"  
> > }  
> > }, {  
> > "term" : {  
> > "mynestedcolumn.users.id" : "user1"  
> > }  
> > } ]  
> > }  
> > },  
> > "path" : "mynestedcolumn"  
> > }  
> > }
> > 
> > Still it is returning me the document which it should not.
> > 
> > Please tell me where I am going wrong and suggest if changes required.
> > 
> > Regards,  
> > Rakesh
> > 
> > On Wednesday, May 15, 2013 5:15:20 PM UTC+5:30, Radu Gheorghe wrote:
> > 
> > > Hi Rakesh,
> > > 
> > > Try changing the mapping as I said before, with mynestedcolumn.users as  
> > > the nested type.
> > > 
> > > Then, when you do the query, put the and filter within the nested filter  
> > > and not the other way around. Also, when you refer to fields in the term  
> > > filters, use the full path (eg: mynestedcolumn.users.id).
> > > 
> > > Best regards,  
> > > Radu
> > > 
> > > On Wed, May 15, 2013 at 2:41 PM, rakesh rakshit [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)wrote:
> > > 
> > > > Hi all,
> > > > 
> > > > Here is the query I am firing:
> > > > 
> > > > {  
> > > > "and":[  
> > > > {"nested":  
> > > > {  
> > > > "path":"mynestedcolumn",  
> > > > "query":  
> > > > {  
> > > > "term":  
> > > > {"comment":"dgjkdgjdg"  
> > > > }  
> > > > }  
> > > > }  
> > > > },  
> > > > {"nested":  
> > > > {  
> > > > "path":"mynestedcolumn",  
> > > > "query":  
> > > > {  
> > > > "term":  
> > > > {"id":"user1"  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > ]  
> > > > }
> > > > 
> > > > Regards,  
> > > > Rakesh
> > > > 
> > > > On Wednesday, May 15, 2013 1:14:12 PM UTC+5:30, Radu Gheorghe wrote:
> > > > 
> > > > > Hi Rakesh,
> > > > > 
> > > > > Can you post a curl recreation of your mapping and document (and maybe  
> > > > > also your query that doesn't work as expected) in gist or some similar tool?
> > > > > 
> > > > > I've tried to test by copying what's in your Email and I'm finding it  
> > > > > hard to debug the JSON formatting errors.
> > > > > 
> > > > > One thing that I find wrong so far is that you probably want your  
> > > > > nested objects to be in mynestedcolumn.users, not mynestedcolumn alone.
> > > > > 
> > > > > Best regards,  
> > > > > Radu
> > > > > 
> > > > > On Wed, May 15, 2013 at 9:38 AM, rakesh rakshit \<[ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)
> > > > > 
> > > > > > wrote:
> > > > > 
> > > > > > Hi Radu,
> > > > > > 
> > > > > > Thanks for your response.
> > > > > > 
> > > > > > The usecase is we have a column which is of type nested and can have  
> > > > > > any attribute added dynamically which we dont know about.
> > > > > > 
> > > > > > So our mapping and sample record looks like this:
> > > > > > 
> > > > > > Mapping:  
> > > > > > {
> > > > > > 
> > > > > > ```
> > > > > > "ipdr" : {
> > > > > > "_source" : {
> > > > > > "excludes" : ["column1","column2"],
> > > > > > "includes" : ["mynestedcolumn.*"]
> > > > > > },
> > > > > > "properties" : {
> > > > > > "column1" : {"type" : "string"},
> > > > > > "column2" : {"type" : "string"},
> > > > > > "mynestedcolumn" : {
> > > > > > "type" : "nested"
> > > > > > }
> > > > > > }
> > > > > > }
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > }
> > > > > > 
> > > > > > Record:
> > > > > > 
> > > > > > {  
> > > > > > "column1": "someValue",  
> > > > > > "column2":"anotherValue",  
> > > > > > "mynestedcolumn":  
> > > > > > {  
> > > > > > "serialno" : "7634786",  
> > > > > > "count": 10,  
> > > > > > "users":[  
> > > > > > {  
> > > > > > "id":"user1",  
> > > > > > "comments":[  
> > > > > > {  
> > > > > > "comment":"comment1"  
> > > > > > },  
> > > > > > {  
> > > > > > "comment":"comment2"  
> > > > > > },  
> > > > > > {  
> > > > > > "comment":"comment3"  
> > > > > > }
> > > > > > 
> > > > > > ```
> > > > > > ]
> > > > > > },
> > > > > > {
> > > > > > "id":"user2",
> > > > > > "comments":[
> > > > > > {
> > > > > > "comment":"dgjkdgjdg"
> > > > > > },
> > > > > > {
> > > > > > "comment":"Hows this?"
> > > > > > },
> > > > > > {
> > > > > > "comment":"No comments."
> > > > > > }
> > > > > > 
> > > > > > ]
> > > > > > }
> > > > > > ]
> > > > > > }
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > }
> > > > > > 
> > > > > > Now I want to search a document with id="user1" and comment="Hows  
> > > > > > this?" and ideally this should not return a document.
> > > > > > 
> > > > > > Thanks and Regards,  
> > > > > > Rakesh Kumar Rakshit
> > > > > > 
> > > > > > On Tuesday, May 14, 2013 10:22:32 PM UTC+5:30, Radu Gheorghe wrote:
> > > > > > 
> > > > > > > Hi Rakesh,
> > > > > > > 
> > > > > > > I think you should set obj1 as type Nested:  
> > > > > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/ **g**** uide/reference/mapping/**nested-)  
> > > > > > > \*\*\*\*type/[http://www.elasticsearch.org/guide/reference/mapping/nested-type/](http://www.elasticsearch.org/guide/reference/mapping/nested-type/)
> > > > > > > 
> > > > > > > Then, you would need to use nested queries[http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/)and/or  
> > > > > > > filters[http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/)to find those documents.
> > > > > > > 
> > > > > > > ## Best regards, Radu
> > > > > > > 
> > > > > > > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > > > > > > 
> > > > > > > On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit \<  
> > > > > > > [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)\> wrote:
> > > > > > > 
> > > > > > > > Hi all,
> > > > > > > > 
> > > > > > > > I have one of the column which is nested and has structure similar  
> > > > > > > > to this:
> > > > > > > > 
> > > > > > > > { "obj1" : [{ "name" : "blue", "count" : 4 }, { "name" : "green", "count" : 6 }] }
> > > > > > > > 
> > > > > > > > Now if I want to search an object with name= blue and count=6 , ideally this should not get a match but  
> > > > > > > > this happens to find this document as a match.
> > > > > > > > 
> > > > > > > > So I want to get rid of this situation and want that it should not return a match for the above scenario.
> > > > > > > > 
> > > > > > > > How can I overcome this situation?
> > > > > > > > 
> > > > > > > > Can anyone suggest a solution or an alternate way to implement this?
> > > > > > > > 
> > > > > > > > Thanks in advance.
> > > > > > > > 
> > > > > > > > Regards,
> > > > > > > > 
> > > > > > > > Rakesh Kumar Rakshit
> > > > > > > > 
> > > > > > > > --  
> > > > > > > > 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 elasticsearc...@\*\*googlegroups. **c** om.
> > > > > > > > 
> > > > > > > > For more options, visit [https://groups.google.com/\*\*grou](https://groups.google.com/**grou)\*\*\*\*  
> > > > > > > > ps/opt\_out [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > > > > > > 
> > > > > > > --  
> > > > > > > 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 elasticsearc...@\*\*googlegroups.\*\*com.  
> > > > > > > For more options, visit [https://groups.google.com/\*\*grou\*\*ps/opt\_out](https://groups.google.com/ **grou** ps/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > > > .
> > > > > 
> > > > > --  
> > > > > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > > > 
> > > > --  
> > > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).  
> > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > .
> > > 
> > > --  
> > > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![rakesh\_rakshit](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@rakesh\_rakshit](https://discuss.elastic.co/u/rakesh_rakshit)\
**Post date:** [May 16, 2013, 10:23am UTC](https://discuss.elastic.co/t/is-there-a-way-to-overcome-cross-object-search-matches-in-elastic-search-when-using-nested-types/11960/11 "2013-05-16T10:23:40Z")

</div>

Hi Radu,

I am trying this curl recreation and getting error as follows:

curl -XGET "[http://localhost:9200/myindex/idpr/\_search](http://localhost:9200/myindex/idpr/_search)" -d '{"query":

> {"nested" : {  
> "path" : "mynestedcolumn",  
> "score\_mode" : "avg",  
> "query" : {  
> "bool" : {  
> "must" : [{  
> "match" : {"mynestedcolumn.users.id" : "user1"}  
> },  
> {  
> "match" :  
> {"mynestedcolumn.users.comments.comment" : "dgjkdgjdg"}  
> }  
> ]  
> }  
> }  
> }  
> }  
> }'  
> {"error":"SearchPhaseExecutionException[Failed to execute phase [query],  
> total failure; shardFailures {[XPZH6bCCTd-e0GzlbMVz1Q][myindex][1]:  
> SearchParseException[[myindex][1]: from[-1],size[-1]: Parse Failure [Failed  
> to parse source [{"query":\n{"nested" : {\n "path" :  
> "mynestedcolumn",\n "score\_mode" : "avg",\n "query" :  
> {\n "bool" : {\n "must" :  
> [{\n "match" : {"mynestedcolumn.users.id" :  
> "user1"}\n },\n  
> {\n "match" :  
> {"mynestedcolumn.users.comments.comment" :  
> "dgjkdgjdg"}\n }\n ]\n  
> }\n }\n }\n}\n}]]]; nested: QueryParsingException[[myindex]  
> [nested] failed to find nested object under path [mynestedcolumn]];  
> }{[XPZH6bCCTd-e0GzlbMVz1Q][myindex][2]: SearchParseException[[myindex][2]:  
> from[-1],size[-1]: Parse Failure [Failed to parse source  
> [{"query":\n{"nested" : {\n "path" :  
> "mynestedcolumn",\n "score\_mode" : "avg",\n "query" :  
> {\n "bool" : {\n "must" :  
> [{\n "match" : {"mynestedcolumn.users.id" :  
> "user1"}\n },\n  
> {\n "match" :  
> {"mynestedcolumn.users.comments.comment" :  
> "dgjkdgjdg"}\n }\n ]\n  
> }\n }\n }\n}\n}]]]; nested: QueryParsingException[[myindex]  
> [nested] failed to find nested object under path [mynestedcolumn]];  
> }{[XPZH6bCCTd-e0GzlbMVz1Q][myindex][4]: SearchParseException[[myindex][4]:  
> from[-1],size[-1]: Parse Failure [Failed to parse source  
> [{"query":\n{"nested" : {\n "path" :  
> "mynestedcolumn",\n "score\_mode" : "avg",\n "query" :  
> {\n "bool" : {\n "must" :  
> [{\n "match" : {"mynestedcolumn.users.id" :  
> "user1"}\n },\n  
> {\n "match" :  
> {"mynestedcolumn.users.comments.comment" :  
> "dgjkdgjdg"}\n }\n ]\n  
> }\n }\n }\n}\n}]]]; nested: QueryParsingException[[myindex]  
> [nested] failed to find nested object under path [mynestedcolumn]];  
> }{[XPZH6bCCTd-e0GzlbMVz1Q][myindex][3]: SearchParseException[[myindex][3]:  
> from[-1],size[-1]: Parse Failure [Failed to parse source  
> [{"query":\n{"nested" : {\n "path" :  
> "mynestedcolumn",\n "score\_mode" : "avg",\n "query" :  
> {\n "bool" : {\n "must" :  
> [{\n "match" : {"mynestedcolumn.users.id" :  
> "user1"}\n },\n  
> {\n "match" :  
> {"mynestedcolumn.users.comments.comment" :  
> "dgjkdgjdg"}\n }\n ]\n  
> }\n }\n }\n}\n}]]]; nested: QueryParsingException[[myindex]  
> [nested] failed to find nested object under path [mynestedcolumn]];  
> }{[XPZH6bCCTd-e0GzlbMVz1Q][myindex][0]: SearchParseException[[myindex][0]:  
> from[-1],size[-1]: Parse Failure [Failed to parse source  
> [{"query":\n{"nested" : {\n "path" :  
> "mynestedcolumn",\n "score\_mode" : "avg",\n "query" :  
> {\n "bool" : {\n "must" :  
> [{\n "match" : {"mynestedcolumn.users.id" :  
> "user1"}\n },\n  
> {\n "match" :  
> {"mynestedcolumn.users.comments.comment" :  
> "dgjkdgjdg"}\n }\n ]\n  
> }\n }\n }\n}\n}]]]; nested: QueryParsingException[[myindex]  
> [nested] failed to find nested object under path [mynestedcolumn]];  
> }]","status":500}

Regards,  
Rakesh

On Thursday, May 16, 2013 3:21:16 PM UTC+5:30, rakesh rakshit wrote:

> Hi Radu,
> 
> I am using the Elastic search java api to fire the query and finding it  
> difficult since I created a curl recreation for the same but it is giving  
> errors. I am trying it and will provide it as soon as it works.
> 
> Regards,  
> Rakesh
> 
> On Thursday, May 16, 2013 12:37:17 PM UTC+5:30, Radu Gheorghe wrote:
> 
> > Hi Rakesh,
> > 
> > Can you provide a curl recreation [http://www.elasticsearch.org/help/](http://www.elasticsearch.org/help/)of the problem? It's hard for me to copy paste from the Email.
> > 
> > Best regards,  
> > Radu
> > 
> > On Thu, May 16, 2013 at 9:46 AM, rakesh rakshit [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)wrote:
> > 
> > > Hi Radu,
> > > 
> > > I changed the mapping to this:
> > > 
> > > {  
> > > "ipdr" : {  
> > > "properties" : {  
> > > "c0" : {"type" : "string"},  
> > > "c1" : {"type" : "string"},  
> > > "mynestedcolumn" : { "type" : "nested"},  
> > > "mynestedcolumn.users" : { "type" : "nested"},  
> > > "mynestedcolumn.users.comments" : { "type" : "nested"},  
> > > }  
> > > }  
> > > }
> > > 
> > > And my search query to this:
> > > 
> > > {  
> > > "nested" : {  
> > > "filter" : {  
> > > "and" : {  
> > > "filters" : [ {  
> > > "term" : {  
> > > "mynestedcolumn.users.comments.comment" : "dgjkdgjdg"  
> > > }  
> > > }, {  
> > > "term" : {  
> > > "mynestedcolumn.users.id" : "user1"  
> > > }  
> > > } ]  
> > > }  
> > > },  
> > > "path" : "mynestedcolumn"  
> > > }  
> > > }
> > > 
> > > Still it is returning me the document which it should not.
> > > 
> > > Please tell me where I am going wrong and suggest if changes required.
> > > 
> > > Regards,  
> > > Rakesh
> > > 
> > > On Wednesday, May 15, 2013 5:15:20 PM UTC+5:30, Radu Gheorghe wrote:
> > > 
> > > > Hi Rakesh,
> > > > 
> > > > Try changing the mapping as I said before, with mynestedcolumn.users  
> > > > as the nested type.
> > > > 
> > > > Then, when you do the query, put the and filter within the nested  
> > > > filter and not the other way around. Also, when you refer to fields in the  
> > > > term filters, use the full path (eg: mynestedcolumn.users.id).
> > > > 
> > > > Best regards,  
> > > > Radu
> > > > 
> > > > On Wed, May 15, 2013 at 2:41 PM, rakesh rakshit [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)wrote:
> > > > 
> > > > > Hi all,
> > > > > 
> > > > > Here is the query I am firing:
> > > > > 
> > > > > {  
> > > > > "and":[  
> > > > > {"nested":  
> > > > > {  
> > > > > "path":"mynestedcolumn",  
> > > > > "query":  
> > > > > {  
> > > > > "term":  
> > > > > {"comment":"dgjkdgjdg"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > },  
> > > > > {"nested":  
> > > > > {  
> > > > > "path":"mynestedcolumn",  
> > > > > "query":  
> > > > > {  
> > > > > "term":  
> > > > > {"id":"user1"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > ]  
> > > > > }
> > > > > 
> > > > > Regards,  
> > > > > Rakesh
> > > > > 
> > > > > On Wednesday, May 15, 2013 1:14:12 PM UTC+5:30, Radu Gheorghe wrote:
> > > > > 
> > > > > > Hi Rakesh,
> > > > > > 
> > > > > > Can you post a curl recreation of your mapping and document (and  
> > > > > > maybe also your query that doesn't work as expected) in gist or some  
> > > > > > similar tool?
> > > > > > 
> > > > > > I've tried to test by copying what's in your Email and I'm finding it  
> > > > > > hard to debug the JSON formatting errors.
> > > > > > 
> > > > > > One thing that I find wrong so far is that you probably want your  
> > > > > > nested objects to be in mynestedcolumn.users, not mynestedcolumn alone.
> > > > > > 
> > > > > > Best regards,  
> > > > > > Radu
> > > > > > 
> > > > > > On Wed, May 15, 2013 at 9:38 AM, rakesh rakshit \<  
> > > > > > [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)\> wrote:
> > > > > > 
> > > > > > > Hi Radu,
> > > > > > > 
> > > > > > > Thanks for your response.
> > > > > > > 
> > > > > > > The usecase is we have a column which is of type nested and can have  
> > > > > > > any attribute added dynamically which we dont know about.
> > > > > > > 
> > > > > > > So our mapping and sample record looks like this:
> > > > > > > 
> > > > > > > Mapping:  
> > > > > > > {
> > > > > > > 
> > > > > > > ```
> > > > > > > "ipdr" : {
> > > > > > > "_source" : {
> > > > > > > "excludes" : ["column1","column2"],
> > > > > > > "includes" : ["mynestedcolumn.*"]
> > > > > > > },
> > > > > > > "properties" : {
> > > > > > > "column1" : {"type" : "string"},
> > > > > > > "column2" : {"type" : "string"},
> > > > > > > "mynestedcolumn" : {
> > > > > > > "type" : "nested"
> > > > > > > }
> > > > > > > }
> > > > > > > }
> > > > > > > 
> > > > > > > ```
> > > > > > > 
> > > > > > > }
> > > > > > > 
> > > > > > > Record:
> > > > > > > 
> > > > > > > {  
> > > > > > > "column1": "someValue",  
> > > > > > > "column2":"anotherValue",  
> > > > > > > "mynestedcolumn":  
> > > > > > > {  
> > > > > > > "serialno" : "7634786",  
> > > > > > > "count": 10,  
> > > > > > > "users":[  
> > > > > > > {  
> > > > > > > "id":"user1",  
> > > > > > > "comments":[  
> > > > > > > {  
> > > > > > > "comment":"comment1"  
> > > > > > > },  
> > > > > > > {  
> > > > > > > "comment":"comment2"  
> > > > > > > },  
> > > > > > > {  
> > > > > > > "comment":"comment3"  
> > > > > > > }
> > > > > > > 
> > > > > > > ```
> > > > > > > ]
> > > > > > > },
> > > > > > > {
> > > > > > > "id":"user2",
> > > > > > > "comments":[
> > > > > > > {
> > > > > > > "comment":"dgjkdgjdg"
> > > > > > > },
> > > > > > > {
> > > > > > > "comment":"Hows this?"
> > > > > > > },
> > > > > > > {
> > > > > > > "comment":"No comments."
> > > > > > > }
> > > > > > > 
> > > > > > > ]
> > > > > > > }
> > > > > > > ]
> > > > > > > }
> > > > > > > 
> > > > > > > ```
> > > > > > > 
> > > > > > > }
> > > > > > > 
> > > > > > > Now I want to search a document with id="user1" and comment="Hows  
> > > > > > > this?" and ideally this should not return a document.
> > > > > > > 
> > > > > > > Thanks and Regards,  
> > > > > > > Rakesh Kumar Rakshit
> > > > > > > 
> > > > > > > On Tuesday, May 14, 2013 10:22:32 PM UTC+5:30, Radu Gheorghe wrote:
> > > > > > > 
> > > > > > > > Hi Rakesh,
> > > > > > > > 
> > > > > > > > I think you should set obj1 as type Nested:  
> > > > > > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/ **g**** uide/reference/mapping/)\*\*  
> > > > > > > > nested-\*\*\*\*type/[http://www.elasticsearch.org/guide/reference/mapping/nested-type/](http://www.elasticsearch.org/guide/reference/mapping/nested-type/)
> > > > > > > > 
> > > > > > > > Then, you would need to use nested queries[http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/)and/or  
> > > > > > > > filters[http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/)to find those documents.
> > > > > > > > 
> > > > > > > > ## Best regards, Radu
> > > > > > > > 
> > > > > > > > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > > > > > > > 
> > > > > > > > On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit \<  
> > > > > > > > [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)\> wrote:
> > > > > > > > 
> > > > > > > > > Hi all,
> > > > > > > > > 
> > > > > > > > > I have one of the column which is nested and has structure similar  
> > > > > > > > > to this:
> > > > > > > > > 
> > > > > > > > > { "obj1" : [{ "name" : "blue", "count" : 4 }, { "name" : "green", "count" : 6 }] }
> > > > > > > > > 
> > > > > > > > > Now if I want to search an object with name= blue and count=6 , ideally this should not get a match but  
> > > > > > > > > this happens to find this document as a match.
> > > > > > > > > 
> > > > > > > > > So I want to get rid of this situation and want that it should not return a match for the above scenario.
> > > > > > > > > 
> > > > > > > > > How can I overcome this situation?
> > > > > > > > > 
> > > > > > > > > Can anyone suggest a solution or an alternate way to implement this?
> > > > > > > > > 
> > > > > > > > > Thanks in advance.
> > > > > > > > > 
> > > > > > > > > Regards,
> > > > > > > > > 
> > > > > > > > > Rakesh Kumar Rakshit
> > > > > > > > > 
> > > > > > > > > --  
> > > > > > > > > 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 elasticsearc...@\*\*googlegroups. **c** om.
> > > > > > > > > 
> > > > > > > > > For more options, visit [https://groups.google.com/\*\*grou](https://groups.google.com/**grou)\*\*\*\*  
> > > > > > > > > ps/opt\_out [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > > > > > > > 
> > > > > > > > --  
> > > > > > > > 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 elasticsearc...@\*\*googlegroups.\*\*com.  
> > > > > > > > For more options, visit [https://groups.google.com/\*\*grou\*\*ps/opt\_out](https://groups.google.com/ **grou** ps/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > > > > .
> > > > > > 
> > > > > > --  
> > > > > > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > > > > 
> > > > > --  
> > > > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).  
> > > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > .
> > > > 
> > > > --  
> > > > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > --  
> > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![rakesh\_rakshit](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@rakesh\_rakshit](https://discuss.elastic.co/u/rakesh_rakshit)\
**Post date:** [May 16, 2013, 10:32am UTC](https://discuss.elastic.co/t/is-there-a-way-to-overcome-cross-object-search-matches-in-elastic-search-when-using-nested-types/11960/12 "2013-05-16T10:32:13Z")

</div>

Hi Radu,

Here is the curl recreation of the problem. I should not get any document  
with this query but it returned a hit.

curl -XGET "[http://localhost:9200/myindex/myindex/\_search?pretty=true](http://localhost:9200/myindex/myindex/_search?pretty=true)" -d  
'{"query":  
{"nested" : {  
"path" : "mynestedcolumn",  
"score\_mode" : "avg",  
"query" : {  
"bool" : {  
"must" : [{  
"match" : {"mynestedcolumn.users.id" : "user1"}  
},  
{  
"match" : {"mynestedcolumn.users.comments.comment"  
: "dgjkdgjdg"}  
}  
]  
}  
}  
}  
}  
}'

Output(This should have no hits) :

{  
"took" : 2,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 1,  
"max\_score" : 0.61871845,  
"hits" : [ {  
"\_index" : "myindex",  
"\_type" : "myindex",  
"\_id" : "1",  
"\_score" : 0.61871845, "\_source" :  
{"mynestedcolumn":{"users":[{"id":"user1","comments":[{"comment":"Hadoop  
likes."},{"comment":"I love ES."},{"comment":"Too many  
features."}]},{"id":"user2","comments":[{"comment":"dgjkdgjdg"},{"comment":"Hows  
this?"},{"comment":"No  
comments."}]}],"seqno":"7634786","packages":[{"id":"1608","packageresourcestatus":2}],"bookmark":10}}  
} ]  
}  
}

Regards,  
Rakesh

On Thursday, May 16, 2013 12:37:17 PM UTC+5:30, Radu Gheorghe wrote:

> Hi Rakesh,
> 
> Can you provide a curl recreation [http://www.elasticsearch.org/help/](http://www.elasticsearch.org/help/) of  
> the problem? It's hard for me to copy paste from the Email.
> 
> Best regards,  
> Radu
> 
> On Thu, May 16, 2013 at 9:46 AM, rakesh rakshit \<[ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi Radu,
> > 
> > I changed the mapping to this:
> > 
> > {  
> > "ipdr" : {  
> > "properties" : {  
> > "c0" : {"type" : "string"},  
> > "c1" : {"type" : "string"},  
> > "mynestedcolumn" : { "type" : "nested"},  
> > "mynestedcolumn.users" : { "type" : "nested"},  
> > "mynestedcolumn.users.comments" : { "type" : "nested"},  
> > }  
> > }  
> > }
> > 
> > And my search query to this:
> > 
> > {  
> > "nested" : {  
> > "filter" : {  
> > "and" : {  
> > "filters" : [ {  
> > "term" : {  
> > "mynestedcolumn.users.comments.comment" : "dgjkdgjdg"  
> > }  
> > }, {  
> > "term" : {  
> > "mynestedcolumn.users.id" : "user1"  
> > }  
> > } ]  
> > }  
> > },  
> > "path" : "mynestedcolumn"  
> > }  
> > }
> > 
> > Still it is returning me the document which it should not.
> > 
> > Please tell me where I am going wrong and suggest if changes required.
> > 
> > Regards,  
> > Rakesh
> > 
> > On Wednesday, May 15, 2013 5:15:20 PM UTC+5:30, Radu Gheorghe wrote:
> > 
> > > Hi Rakesh,
> > > 
> > > Try changing the mapping as I said before, with mynestedcolumn.users as  
> > > the nested type.
> > > 
> > > Then, when you do the query, put the and filter within the nested filter  
> > > and not the other way around. Also, when you refer to fields in the term  
> > > filters, use the full path (eg: mynestedcolumn.users.id).
> > > 
> > > Best regards,  
> > > Radu
> > > 
> > > On Wed, May 15, 2013 at 2:41 PM, rakesh rakshit [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)wrote:
> > > 
> > > > Hi all,
> > > > 
> > > > Here is the query I am firing:
> > > > 
> > > > {  
> > > > "and":[  
> > > > {"nested":  
> > > > {  
> > > > "path":"mynestedcolumn",  
> > > > "query":  
> > > > {  
> > > > "term":  
> > > > {"comment":"dgjkdgjdg"  
> > > > }  
> > > > }  
> > > > }  
> > > > },  
> > > > {"nested":  
> > > > {  
> > > > "path":"mynestedcolumn",  
> > > > "query":  
> > > > {  
> > > > "term":  
> > > > {"id":"user1"  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > ]  
> > > > }
> > > > 
> > > > Regards,  
> > > > Rakesh
> > > > 
> > > > On Wednesday, May 15, 2013 1:14:12 PM UTC+5:30, Radu Gheorghe wrote:
> > > > 
> > > > > Hi Rakesh,
> > > > > 
> > > > > Can you post a curl recreation of your mapping and document (and maybe  
> > > > > also your query that doesn't work as expected) in gist or some similar tool?
> > > > > 
> > > > > I've tried to test by copying what's in your Email and I'm finding it  
> > > > > hard to debug the JSON formatting errors.
> > > > > 
> > > > > One thing that I find wrong so far is that you probably want your  
> > > > > nested objects to be in mynestedcolumn.users, not mynestedcolumn alone.
> > > > > 
> > > > > Best regards,  
> > > > > Radu
> > > > > 
> > > > > On Wed, May 15, 2013 at 9:38 AM, rakesh rakshit \<[ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)
> > > > > 
> > > > > > wrote:
> > > > > 
> > > > > > Hi Radu,
> > > > > > 
> > > > > > Thanks for your response.
> > > > > > 
> > > > > > The usecase is we have a column which is of type nested and can have  
> > > > > > any attribute added dynamically which we dont know about.
> > > > > > 
> > > > > > So our mapping and sample record looks like this:
> > > > > > 
> > > > > > Mapping:  
> > > > > > {
> > > > > > 
> > > > > > ```
> > > > > > "ipdr" : {
> > > > > > "_source" : {
> > > > > > "excludes" : ["column1","column2"],
> > > > > > "includes" : ["mynestedcolumn.*"]
> > > > > > },
> > > > > > "properties" : {
> > > > > > "column1" : {"type" : "string"},
> > > > > > "column2" : {"type" : "string"},
> > > > > > "mynestedcolumn" : {
> > > > > > "type" : "nested"
> > > > > > }
> > > > > > }
> > > > > > }
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > }
> > > > > > 
> > > > > > Record:
> > > > > > 
> > > > > > {  
> > > > > > "column1": "someValue",  
> > > > > > "column2":"anotherValue",  
> > > > > > "mynestedcolumn":  
> > > > > > {  
> > > > > > "serialno" : "7634786",  
> > > > > > "count": 10,  
> > > > > > "users":[  
> > > > > > {  
> > > > > > "id":"user1",  
> > > > > > "comments":[  
> > > > > > {  
> > > > > > "comment":"comment1"  
> > > > > > },  
> > > > > > {  
> > > > > > "comment":"comment2"  
> > > > > > },  
> > > > > > {  
> > > > > > "comment":"comment3"  
> > > > > > }
> > > > > > 
> > > > > > ```
> > > > > > ]
> > > > > > },
> > > > > > {
> > > > > > "id":"user2",
> > > > > > "comments":[
> > > > > > {
> > > > > > "comment":"dgjkdgjdg"
> > > > > > },
> > > > > > {
> > > > > > "comment":"Hows this?"
> > > > > > },
> > > > > > {
> > > > > > "comment":"No comments."
> > > > > > }
> > > > > > 
> > > > > > ]
> > > > > > }
> > > > > > ]
> > > > > > }
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > }
> > > > > > 
> > > > > > Now I want to search a document with id="user1" and comment="Hows  
> > > > > > this?" and ideally this should not return a document.
> > > > > > 
> > > > > > Thanks and Regards,  
> > > > > > Rakesh Kumar Rakshit
> > > > > > 
> > > > > > On Tuesday, May 14, 2013 10:22:32 PM UTC+5:30, Radu Gheorghe wrote:
> > > > > > 
> > > > > > > Hi Rakesh,
> > > > > > > 
> > > > > > > I think you should set obj1 as type Nested:  
> > > > > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/ **g**** uide/reference/mapping/**nested-)  
> > > > > > > \*\*\*\*type/[http://www.elasticsearch.org/guide/reference/mapping/nested-type/](http://www.elasticsearch.org/guide/reference/mapping/nested-type/)
> > > > > > > 
> > > > > > > Then, you would need to use nested queries[http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/)and/or  
> > > > > > > filters[http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/)to find those documents.
> > > > > > > 
> > > > > > > ## Best regards, Radu
> > > > > > > 
> > > > > > > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > > > > > > 
> > > > > > > On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit \<  
> > > > > > > [ihavethe...@gmail.com](mailto:ihavethe...@gmail.com)\> wrote:
> > > > > > > 
> > > > > > > > Hi all,
> > > > > > > > 
> > > > > > > > I have one of the column which is nested and has structure similar  
> > > > > > > > to this:
> > > > > > > > 
> > > > > > > > { "obj1" : [{ "name" : "blue", "count" : 4 }, { "name" : "green", "count" : 6 }] }
> > > > > > > > 
> > > > > > > > Now if I want to search an object with name= blue and count=6 , ideally this should not get a match but  
> > > > > > > > this happens to find this document as a match.
> > > > > > > > 
> > > > > > > > So I want to get rid of this situation and want that it should not return a match for the above scenario.
> > > > > > > > 
> > > > > > > > How can I overcome this situation?
> > > > > > > > 
> > > > > > > > Can anyone suggest a solution or an alternate way to implement this?
> > > > > > > > 
> > > > > > > > Thanks in advance.
> > > > > > > > 
> > > > > > > > Regards,
> > > > > > > > 
> > > > > > > > Rakesh Kumar Rakshit
> > > > > > > > 
> > > > > > > > --  
> > > > > > > > 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 elasticsearc...@\*\*googlegroups. **c** om.
> > > > > > > > 
> > > > > > > > For more options, visit [https://groups.google.com/\*\*grou](https://groups.google.com/**grou)\*\*\*\*  
> > > > > > > > ps/opt\_out [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > > > > > > 
> > > > > > > --  
> > > > > > > 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 elasticsearc...@\*\*googlegroups.\*\*com.  
> > > > > > > For more options, visit [https://groups.google.com/\*\*grou\*\*ps/opt\_out](https://groups.google.com/ **grou** ps/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > > > .
> > > > > 
> > > > > --  
> > > > > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > > > 
> > > > --  
> > > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).  
> > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > .
> > > 
> > > --  
> > > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:36am UTC](https://discuss.elastic.co/t/is-there-a-way-to-overcome-cross-object-search-matches-in-elastic-search-when-using-nested-types/11960/13 "2017-07-06T02:36:19Z")

</div>


