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

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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Rakesh,

I think you should set obj1 as type Nested:

Then, you would need to use nested
querieshttp://www.elasticsearch.org/guide/reference/query-dsl/nested-query/and/or
filtershttp://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/to
find those documents.

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit <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.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

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

Then, you would need to use nested querieshttp://www.elasticsearch.org/guide/reference/query-dsl/nested-query/and/or
filtershttp://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/to find those documents.

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit <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 <javascript:>.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

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> 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 | Elastichttp://www.elasticsearch.org/guide/reference/mapping/nested-type/

Then, you would need to use nested querieshttp://www.elasticsearch.org/guide/reference/query-dsl/nested-query/and/or
filtershttp://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/to find those documents.

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit ihavethe...@gmail.comwrote:

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/**groups/opt_outhttps://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.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

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

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 | Elastichttp://www.elasticsearch.org/guide/reference/mapping/nested-type/

Then, you would need to use nested querieshttp://www.elasticsearch.org/guide/reference/query-dsl/nested-query/and/or
filtershttp://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/to find those documents.

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit ihavethe...@gmail.comwrote:

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/**groups/opt_outhttps://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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

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<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 | Elastichttp://www.elasticsearch.org/guide/reference/mapping/nested-type/

Then, you would need to use nested querieshttp://www.elasticsearch.org/guide/reference/query-dsl/nested-query/and/or
filtershttp://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/to find those documents.

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit ihavethe...@gmail.comwrote:

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/**groups/opt_outhttps://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 <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

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

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.comwrote:

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**
type/http://www.elasticsearch.org/guide/reference/mapping/nested-type/

Then, you would need to use nested querieshttp://www.elasticsearch.org/guide/reference/query-dsl/nested-query/and/or
filtershttp://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/to find those documents.

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit <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_outhttps://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/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

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<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.comwrote:

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**
type/http://www.elasticsearch.org/guide/reference/mapping/nested-type/

Then, you would need to use nested querieshttp://www.elasticsearch.org/guide/reference/query-dsl/nested-query/and/or
filtershttp://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/to find those documents.

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit <
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_outhttps://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/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
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 <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Rakesh,

Can you provide a curl recreation 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

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.comwrote:

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.comwrote:

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*
***type/http://www.elasticsearch.org/guide/reference/mapping/nested-type/

Then, you would need to use nested querieshttp://www.elasticsearch.org/guide/reference/query-dsl/nested-query/and/or
filtershttp://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/to find those documents.

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit <
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/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_outhttps://groups.google.com/groups/opt_out
.

--
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.
For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

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/ 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<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.comwrote:

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

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
****type/http://www.elasticsearch.org/guide/reference/mapping/nested-type/

Then, you would need to use nested querieshttp://www.elasticsearch.org/guide/reference/query-dsl/nested-query/and/or
filtershttp://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/to find those documents.

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit <
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/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_outhttps://groups.google.com/groups/opt_out
.

--
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.
For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
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 <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Radu,

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

curl -XGET "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/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.comwrote:

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.comwrote:

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> 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**
nested-****type/http://www.elasticsearch.org/guide/reference/mapping/nested-type/

Then, you would need to use nested querieshttp://www.elasticsearch.org/guide/reference/query-dsl/nested-query/and/or
filtershttp://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/to find those documents.

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit <
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/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_outhttps://groups.google.com/groups/opt_out
.

--
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.
For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

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" -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/ 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<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.comwrote:

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

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
****type/http://www.elasticsearch.org/guide/reference/mapping/nested-type/

Then, you would need to use nested querieshttp://www.elasticsearch.org/guide/reference/query-dsl/nested-query/and/or
filtershttp://www.elasticsearch.org/guide/reference/query-dsl/nested-filter/to find those documents.

Best regards,
Radu

http://sematext.com/ -- Elasticsearch -- Solr -- Lucene

On Tue, May 14, 2013 at 7:15 PM, rakesh rakshit <
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/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_outhttps://groups.google.com/groups/opt_out
.

--
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.
For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
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 <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.