Searching across parent and child

Hi,

I am working on an application that uses ElasticSearch for providing a
searching across the application. Now I have a scenario where a Product can
have many variations depending on it's colors. So a product A available in
Blue and Green will have 2 Product variations and a Product entity indexed
into ES. Now each of the product variations will contain some specific
fields not present in the Product domain. Also I have marked the Product -
ProductVariation relationship with a parent-child relationship(Product
being the parent).

Now I have a case of searching for a products using a free text search.
Since I have different fields in those domains, I would have to search
across both the domains. What I would essentially like to have is that I
make a single query to search across a product and it's related child
ProductVariation to get a match Eg: Blue jeans search should search across
both where blue is the color present in ProductVariation and Jeans is a
category in Product. Also I intend to provide filtering/faceting over these
fields.

How would I do a search and across which domain. I am tried out the
has_child and has_parent queries but am a bit skeptical about the results.

Any help would be greatly appreciated.

Regards
Manoj Mohan

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

Bumping this thread... really need some solution for this ...

Regards
Manoj Mohan
Intelligrape Software

On Tue, Jul 30, 2013 at 3:26 PM, Manoj Mohan manoj@intelligrape.com wrote:

Hi,

I am working on an application that uses Elasticsearch for providing a
searching across the application. Now I have a scenario where a Product can
have many variations depending on it's colors. So a product A available in
Blue and Green will have 2 Product variations and a Product entity indexed
into ES. Now each of the product variations will contain some specific
fields not present in the Product domain. Also I have marked the Product -
ProductVariation relationship with a parent-child relationship(Product
being the parent).

Now I have a case of searching for a products using a free text search.
Since I have different fields in those domains, I would have to search
across both the domains. What I would essentially like to have is that I
make a single query to search across a product and it's related child
ProductVariation to get a match Eg: Blue jeans search should search across
both where blue is the color present in ProductVariation and Jeans is a
category in Product. Also I intend to provide filtering/faceting over these
fields.

How would I do a search and across which domain. I am tried out the
has_child and has_parent queries but am a bit skeptical about the results.

Any help would be greatly appreciated.

Regards
Manoj Mohan

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe.
To unsubscribe from this group and all its topics, 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.

From my POV: stay away from has_child and has_parent query if you need
facets - that can't work: you will not be able to perform "color" facet if
the field is not on the product document.

My best guest whould be that the product document should host his
variations (maybe in a nested objecthttp://www.elasticsearch.org/guide/reference/mapping/nested-type/to ease the query against some variation only).

Having everything in the same doc will also ease indexing & update & query
against everything.

My 2cts :wink:
Damien

On Tuesday, July 30, 2013 11:56:56 AM UTC+2, Manoj Mohan wrote:

Hi,

I am working on an application that uses Elasticsearch for providing a
searching across the application. Now I have a scenario where a Product can
have many variations depending on it's colors. So a product A available in
Blue and Green will have 2 Product variations and a Product entity indexed
into ES. Now each of the product variations will contain some specific
fields not present in the Product domain. Also I have marked the Product -
ProductVariation relationship with a parent-child relationship(Product
being the parent).

Now I have a case of searching for a products using a free text search.
Since I have different fields in those domains, I would have to search
across both the domains. What I would essentially like to have is that I
make a single query to search across a product and it's related child
ProductVariation to get a match Eg: Blue jeans search should search across
both where blue is the color present in ProductVariation and Jeans is a
category in Product. Also I intend to provide filtering/faceting over these
fields.

How would I do a search and across which domain. I am tried out the
has_child and has_parent queries but am a bit skeptical about the results.

Any help would be greatly appreciated.

Regards
Manoj Mohan

--
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 for the reply Damien.

But the problem with nested objects is that there can be a cross match that
results in a fake result as mentioned in this doc
Elasticsearch Platform — Find real-time answers at scale | Elastic.
So a product having 2 variations -

Price : $50
Color:Blue

Price: $20
Color:Black

Here searching for a Blue colored product under $30 would give back the
product having the above variations, which is a big problem there isn't a
variation that matches the criteria.

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 1:56 PM, Damien Alexandre dalexandre@jolicode.comwrote:

From my POV: stay away from has_child and has_parent query if you need
facets - that can't work: you will not be able to perform "color" facet if
the field is not on the product document.

My best guest whould be that the product document should host his
variations (maybe in a nested objecthttp://www.elasticsearch.org/guide/reference/mapping/nested-type/to ease the query against some variation only).

Having everything in the same doc will also ease indexing & update & query
against everything.

My 2cts :wink:
Damien

On Tuesday, July 30, 2013 11:56:56 AM UTC+2, Manoj Mohan wrote:

Hi,

I am working on an application that uses Elasticsearch for providing a
searching across the application. Now I have a scenario where a Product can
have many variations depending on it's colors. So a product A available in
Blue and Green will have 2 Product variations and a Product entity indexed
into ES. Now each of the product variations will contain some specific
fields not present in the Product domain. Also I have marked the Product -
ProductVariation relationship with a parent-child relationship(Product
being the parent).

Now I have a case of searching for a products using a free text search.
Since I have different fields in those domains, I would have to search
across both the domains. What I would essentially like to have is that I
make a single query to search across a product and it's related child
ProductVariation to get a match Eg: Blue jeans search should search across
both where blue is the color present in ProductVariation and Jeans is a
category in Product. Also I intend to provide filtering/faceting over these
fields.

How would I do a search and across which domain. I am tried out the
has_child and has_parent queries but am a bit skeptical about the results.

Any help would be greatly appreciated.

Regards
Manoj Mohan

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe.
To unsubscribe from this group and all its topics, 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.

On Tuesday, August 6, 2013 11:51:33 AM UTC+2, Manoj Mohan wrote:

Thanks for the reply Damien.

But the problem with nested objects is that there can be a cross match
that results in a fake result as mentioned in this doc
Elasticsearch Platform — Find real-time answers at scale | Elastic.
So a product having 2 variations -

Price : $50
Color:Blue

Price: $20
Color:Black

Here searching for a Blue colored product under $30 would give back the
product having the above variations, which is a big problem there isn't a
variation that matches the criteria.

This can be avoid using
NestedQuery: Elasticsearch Platform — Find real-time answers at scale | Elastic
(or filter).
I use them a lot and that works fine for this case.

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 1:56 PM, Damien Alexandre <dalex...@jolicode.com<javascript:>

wrote:

From my POV: stay away from has_child and has_parent query if you need
facets - that can't work: you will not be able to perform "color" facet if
the field is not on the product document.

My best guest whould be that the product document should host his
variations (maybe in a nested objecthttp://www.elasticsearch.org/guide/reference/mapping/nested-type/to ease the query against some variation only).

Having everything in the same doc will also ease indexing & update &
query against everything.

My 2cts :wink:
Damien

On Tuesday, July 30, 2013 11:56:56 AM UTC+2, Manoj Mohan wrote:

Hi,

I am working on an application that uses Elasticsearch for providing a
searching across the application. Now I have a scenario where a Product can
have many variations depending on it's colors. So a product A available in
Blue and Green will have 2 Product variations and a Product entity indexed
into ES. Now each of the product variations will contain some specific
fields not present in the Product domain. Also I have marked the Product -
ProductVariation relationship with a parent-child relationship(Product
being the parent).

Now I have a case of searching for a products using a free text search.
Since I have different fields in those domains, I would have to search
across both the domains. What I would essentially like to have is that I
make a single query to search across a product and it's related child
ProductVariation to get a match Eg: Blue jeans search should search across
both where blue is the color present in ProductVariation and Jeans is a
category in Product. Also I intend to provide filtering/faceting over these
fields.

How would I do a search and across which domain. I am tried out the
has_child and has_parent queries but am a bit skeptical about the results.

Any help would be greatly appreciated.

Regards
Manoj Mohan

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe.
To unsubscribe from this group and all its topics, 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.

Thanks Damien.
*
*
It seems to work now with a Nested Filter. I had tried it out earlier
before asking this question in the Elasticsearch HEAD
pluginhttp://mobz.github.io/elasticsearch-head/,
but it seemed to fail using the GET call. I now tried it out using a POST
call for which it seems to work. Using the CURL command it works for both
scenarios.

I then tried out using the Nested Query for which I can't seem to make
it work
. Here's a mapping of the index against which I am trying it out..

  • mappings: {
    • nested_author: {
      • properties: {
        • books: {
          • properties: {
            • genre: {
              • type: string
                }
            • name: {
              • type: string
                }
            • publisher: {
              • type: string
                }
                }
          • type: nested
            }
        • name: {
          • type: string
            }
            }
            }
            }

Some test data ...

curl -XPUT localhost:9200/authors/nested_author/1 -d'{
"name": "Multi G. Enre",
"books": [
{

  • "name": "Guns and lasers",*

  • "genre": "scifi",*

  • "publisher": "orbit"*
    },
    {

  • "name": "Dead in the night",*

  • "genre": "thriller",*

  • "publisher": "penguin"*
    }
    ]
    }'

curl -XPUT localhost:9200/authors/nested_author/2 -d'{
"name": "Alastair Reynolds",
"books": [
{

  • "name": "Revelation Space",*
  • "genre": "scifi",*
  • "publisher": "penguin"*
    }
    ]
    }'

I made this query to search for records, but it results in a *
SearchPhaseExecutionException*

curl -XPOST localhost:9200/authors/nested_author/_search -d '
{

  •        "nested" : {*
    
  •        "path" : "books",*
    
  •        "score_mode" : "avg",*
    
  •        "query" : {*
    
  •            "bool" : {*
    
  •                "must" : [*
    
  •                        {*
    
  •                            "term": {"books.publisher": "orbit"}*
    
  •                        },*
    
  •                        {*
    
  •                            "term": {"books.genre": "thriller"}*
    
  •                        }*
    
  •                ]*
    
  •            }*
    
  •        }*
    
  •    }*
    
  •    }'*
    

Can you spot any issues with the query or the mapping itself for which the
query might be failing ???

Thanks again.. You have been of great help.

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 3:25 PM, Damien Alexandre dalexandre@jolicode.comwrote:

On Tuesday, August 6, 2013 11:51:33 AM UTC+2, Manoj Mohan wrote:

Thanks for the reply Damien.

But the problem with nested objects is that there can be a cross match
that results in a fake result as mentioned in this doc
http://www.elasticsearch.**org/guide/reference/mapping/**nested-type/http://www.elasticsearch.org/guide/reference/mapping/nested-type/
.
So a product having 2 variations -

Price : $50
Color:Blue

Price: $20
Color:Black

Here searching for a Blue colored product under $30 would give back the
product having the above variations, which is a big problem there isn't a
variation that matches the criteria.

This can be avoid using NestedQuery:
Elasticsearch Platform — Find real-time answers at scale | Elastic (or
filter).
I use them a lot and that works fine for this case.

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 1:56 PM, Damien Alexandre dalex...@jolicode.comwrote:

From my POV: stay away from has_child and has_parent query if you need
facets - that can't work: you will not be able to perform "color" facet if
the field is not on the product document.

My best guest whould be that the product document should host his
variations (maybe in a nested objecthttp://www.elasticsearch.org/guide/reference/mapping/nested-type/to ease the query against some variation only).

Having everything in the same doc will also ease indexing & update &
query against everything.

My 2cts :wink:
Damien

On Tuesday, July 30, 2013 11:56:56 AM UTC+2, Manoj Mohan wrote:

Hi,

I am working on an application that uses Elasticsearch for providing a
searching across the application. Now I have a scenario where a Product can
have many variations depending on it's colors. So a product A available in
Blue and Green will have 2 Product variations and a Product entity indexed
into ES. Now each of the product variations will contain some specific
fields not present in the Product domain. Also I have marked the Product -
ProductVariation relationship with a parent-child relationship(Product
being the parent).

Now I have a case of searching for a products using a free text search.
Since I have different fields in those domains, I would have to search
across both the domains. What I would essentially like to have is that I
make a single query to search across a product and it's related child
ProductVariation to get a match Eg: Blue jeans search should search across
both where blue is the color present in ProductVariation and Jeans is a
category in Product. Also I intend to provide filtering/faceting over these
fields.

How would I do a search and across which domain. I am tried out the
has_child and has_parent queries but am a bit skeptical about the results.

Any help would be greatly appreciated.

Regards
Manoj Mohan

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/**
topic/elasticsearch/Y-**AxvhSyhXU/unsubscribehttps://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe
.
To unsubscribe from this group and all its topics, 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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe.
To unsubscribe from this group and all its topics, 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.

Hey finally figured out the issue.. I hadn't wrapped the query in a "query"
format .. and it works ..

curl -XPOST localhost:9200/authors/nested_author/_search -d '
{

  • "query": {** *
  • "nested" : {*
    
  •        "path" : "books",*
    
  •        "score_mode" : "avg",*
    
  •        "query" : {*
    
  •            "bool" : {*
    
  •                "must" : [*
    
  •                        {*
    
  •                            "term": {"books.publisher": "orbit"}*
    
  •                        },*
    
  •                        {*
    
  •                            "term": {"books.genre": "thriller"}*
    
  •                        }*
    
  •                ]*
    
  •            }*
    
  •        }*
    
  •    }*
    
  •   }*
    
  •    }'*
    

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 5:46 PM, Manoj Mohan manoj@intelligrape.com wrote:

Thanks Damien.
*
*
It seems to work now with a Nested Filter. I had tried it out earlier
before asking this question in the Elasticsearch HEAD pluginhttp://mobz.github.io/elasticsearch-head/,
but it seemed to fail using the GET call. I now tried it out using a POST
call for which it seems to work. Using the CURL command it works for both
scenarios.

I then tried out using the Nested Query for which I can't seem to make
it work
. Here's a mapping of the index against which I am trying it out..

  • mappings: {
    • nested_author: {
      • properties: {
        • books: {
          • properties: {
            • genre: {
              • type: string
                }
            • name: {
              • type: string
                }
            • publisher: {
              • type: string
                }
                }
          • type: nested
            }
        • name: {
          • type: string
            }
            }
            }
            }

Some test data ...

curl -XPUT localhost:9200/authors/nested_author/1 -d'{
"name": "Multi G. Enre",
"books": [
{

  • "name": "Guns and lasers",*

  • "genre": "scifi",*

  • "publisher": "orbit"*
    },
    {

  • "name": "Dead in the night",*

  • "genre": "thriller",*

  • "publisher": "penguin"*
    }
    ]
    }'

curl -XPUT localhost:9200/authors/nested_author/2 -d'{
"name": "Alastair Reynolds",
"books": [
{

  • "name": "Revelation Space",*
  • "genre": "scifi",*
  • "publisher": "penguin"*
    }
    ]
    }'

I made this query to search for records, but it results in a *
SearchPhaseExecutionException*

curl -XPOST localhost:9200/authors/nested_author/_search -d '
{

  •        "nested" : {*
    
  •        "path" : "books",*
    
  •        "score_mode" : "avg",*
    
  •        "query" : {*
    
  •            "bool" : {*
    
  •                "must" : [*
    
  •                        {*
    
  •                            "term": {"books.publisher": "orbit"}*
    
  •                        },*
    
  •                        {*
    
  •                            "term": {"books.genre": "thriller"}*
    
  •                        }*
    
  •                ]*
    
  •            }*
    
  •        }*
    
  •    }*
    
  •    }'*
    

Can you spot any issues with the query or the mapping itself for which the
query might be failing ???

Thanks again.. You have been of great help.

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 3:25 PM, Damien Alexandre dalexandre@jolicode.comwrote:

On Tuesday, August 6, 2013 11:51:33 AM UTC+2, Manoj Mohan wrote:

Thanks for the reply Damien.

But the problem with nested objects is that there can be a cross match
that results in a fake result as mentioned in this doc
http://www.elasticsearch.**org/guide/reference/mapping/**nested-type/http://www.elasticsearch.org/guide/reference/mapping/nested-type/
.
So a product having 2 variations -

Price : $50
Color:Blue

Price: $20
Color:Black

Here searching for a Blue colored product under $30 would give back the
product having the above variations, which is a big problem there isn't a
variation that matches the criteria.

This can be avoid using NestedQuery:
Elasticsearch Platform — Find real-time answers at scale | Elastic (or
filter).
I use them a lot and that works fine for this case.

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 1:56 PM, Damien Alexandre dalex...@jolicode.comwrote:

From my POV: stay away from has_child and has_parent query if you need
facets - that can't work: you will not be able to perform "color" facet if
the field is not on the product document.

My best guest whould be that the product document should host his
variations (maybe in a nested objecthttp://www.elasticsearch.org/guide/reference/mapping/nested-type/to ease the query against some variation only).

Having everything in the same doc will also ease indexing & update &
query against everything.

My 2cts :wink:
Damien

On Tuesday, July 30, 2013 11:56:56 AM UTC+2, Manoj Mohan wrote:

Hi,

I am working on an application that uses Elasticsearch for providing a
searching across the application. Now I have a scenario where a Product can
have many variations depending on it's colors. So a product A available in
Blue and Green will have 2 Product variations and a Product entity indexed
into ES. Now each of the product variations will contain some specific
fields not present in the Product domain. Also I have marked the Product -
ProductVariation relationship with a parent-child relationship(Product
being the parent).

Now I have a case of searching for a products using a free text
search. Since I have different fields in those domains, I would have to
search across both the domains. What I would essentially like to have is
that I make a single query to search across a product and it's related
child ProductVariation to get a match Eg: Blue jeans search should search
across both where blue is the color present in ProductVariation and Jeans
is a category in Product. Also I intend to provide filtering/faceting over
these fields.

How would I do a search and across which domain. I am tried out the
has_child and has_parent queries but am a bit skeptical about the results.

Any help would be greatly appreciated.

Regards
Manoj Mohan

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/**
topic/elasticsearch/Y-**AxvhSyhXU/unsubscribehttps://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe
.
To unsubscribe from this group and all its topics, 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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe.
To unsubscribe from this group and all its topics, 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.

Haha yes the missing "query" part is a common mistake :slight_smile:

Also, I also
recommand https://chrome.google.com/webstore/detail/sense/doinijnbnggojdlcjifpdckfokbbfpbo
to write test queries,
it has autocomplete and validation.

Glad I helped you,
Damien

On Tuesday, August 6, 2013 2:36:18 PM UTC+2, Manoj Mohan wrote:

Hey finally figured out the issue.. I hadn't wrapped the query in a
"query" format .. and it works ..

curl -XPOST localhost:9200/authors/nested_author/_search -d '
{

  • "query": {** *
  • "nested" : {*
    
  •        "path" : "books",*
    
  •        "score_mode" : "avg",*
    
  •        "query" : {*
    
  •            "bool" : {*
    
  •                "must" : [*
    
  •                        {*
    
  •                            "term": {"books.publisher": "orbit"}*
    
  •                        },*
    
  •                        {*
    
  •                            "term": {"books.genre": "thriller"}*
    
  •                        }*
    
  •                ]*
    
  •            }*
    
  •        }*
    
  •    }*
    
  •   }*
    
  •    }'*
    

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 5:46 PM, Manoj Mohan <ma...@intelligrape.com<javascript:>

wrote:

Thanks Damien.
*
*
It seems to work now with a Nested Filter. I had tried it out earlier
before asking this question in the Elasticsearch HEAD pluginhttp://mobz.github.io/elasticsearch-head/,
but it seemed to fail using the GET call. I now tried it out using a POST
call for which it seems to work. Using the CURL command it works for both
scenarios.

I then tried out using the Nested Query for which I can't seem to make
it work
. Here's a mapping of the index against which I am trying it
out..

  • mappings: {
    • nested_author: {
      • properties: {
        • books: {
          • properties: {
            • genre: {
              • type: string
                }
            • name: {
              • type: string
                }
            • publisher: {
              • type: string
                }
                }
          • type: nested
            }
        • name: {
          • type: string
            }
            }
            }
            }

Some test data ...

curl -XPUT localhost:9200/authors/nested_author/1 -d'{
"name": "Multi G. Enre",
"books": [
{

  • "name": "Guns and lasers",*

  • "genre": "scifi",*

  • "publisher": "orbit"*
    },
    {

  • "name": "Dead in the night",*

  • "genre": "thriller",*

  • "publisher": "penguin"*
    }
    ]
    }'

curl -XPUT localhost:9200/authors/nested_author/2 -d'{
"name": "Alastair Reynolds",
"books": [
{

  • "name": "Revelation Space",*
  • "genre": "scifi",*
  • "publisher": "penguin"*
    }
    ]
    }'

I made this query to search for records, but it results in a *
SearchPhaseExecutionException*

curl -XPOST localhost:9200/authors/nested_author/_search -d '
{

  •        "nested" : {*
    
  •        "path" : "books",*
    
  •        "score_mode" : "avg",*
    
  •        "query" : {*
    
  •            "bool" : {*
    
  •                "must" : [*
    
  •                        {*
    
  •                            "term": {"books.publisher": "orbit"}*
    
  •                        },*
    
  •                        {*
    
  •                            "term": {"books.genre": "thriller"}*
    
  •                        }*
    
  •                ]*
    
  •            }*
    
  •        }*
    
  •    }*
    
  •    }'*
    

Can you spot any issues with the query or the mapping itself for which
the query might be failing ???

Thanks again.. You have been of great help.

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 3:25 PM, Damien Alexandre <dalex...@jolicode.com<javascript:>

wrote:

On Tuesday, August 6, 2013 11:51:33 AM UTC+2, Manoj Mohan wrote:

Thanks for the reply Damien.

But the problem with nested objects is that there can be a cross match
that results in a fake result as mentioned in this doc
http://www.elasticsearch.**org/guide/reference/mapping/**nested-type/http://www.elasticsearch.org/guide/reference/mapping/nested-type/
.
So a product having 2 variations -

Price : $50
Color:Blue

Price: $20
Color:Black

Here searching for a Blue colored product under $30 would give back the
product having the above variations, which is a big problem there isn't a
variation that matches the criteria.

This can be avoid using NestedQuery:
Elasticsearch Platform — Find real-time answers at scale | Elastic(or filter).
I use them a lot and that works fine for this case.

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 1:56 PM, Damien Alexandre <dalex...@jolicode.com

wrote:

From my POV: stay away from has_child and has_parent query if you
need facets - that can't work: you will not be able to perform "color"
facet if the field is not on the product document.

My best guest whould be that the product document should host his
variations (maybe in a nested objecthttp://www.elasticsearch.org/guide/reference/mapping/nested-type/to ease the query against some variation only).

Having everything in the same doc will also ease indexing & update &
query against everything.

My 2cts :wink:
Damien

On Tuesday, July 30, 2013 11:56:56 AM UTC+2, Manoj Mohan wrote:

Hi,

I am working on an application that uses Elasticsearch for providing
a searching across the application. Now I have a scenario where a Product
can have many variations depending on it's colors. So a product A available
in Blue and Green will have 2 Product variations and a Product entity
indexed into ES. Now each of the product variations will contain some
specific fields not present in the Product domain. Also I have marked the
Product - ProductVariation relationship with a parent-child
relationship(Product being the parent).

Now I have a case of searching for a products using a free text
search. Since I have different fields in those domains, I would have to
search across both the domains. What I would essentially like to have is
that I make a single query to search across a product and it's related
child ProductVariation to get a match Eg: Blue jeans search should search
across both where blue is the color present in ProductVariation and Jeans
is a category in Product. Also I intend to provide filtering/faceting over
these fields.

How would I do a search and across which domain. I am tried out the
has_child and has_parent queries but am a bit skeptical about the results.

Any help would be greatly appreciated.

Regards
Manoj Mohan

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/**
topic/elasticsearch/Y-**AxvhSyhXU/unsubscribehttps://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe
.
To unsubscribe from this group and all its topics, 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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe.
To unsubscribe from this group and all its topics, 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.

Hey this extension's pretty cool ... the autocomplete alone makes it
worthwhile..
Thanks a ton

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 6:20 PM, Damien Alexandre dalexandre@jolicode.comwrote:

Haha yes the missing "query" part is a common mistake :slight_smile:

Also, I also recommand
https://chrome.google.com/webstore/detail/sense/doinijnbnggojdlcjifpdckfokbbfpboto write test queries,
it has autocomplete and validation.

Glad I helped you,
Damien

On Tuesday, August 6, 2013 2:36:18 PM UTC+2, Manoj Mohan wrote:

Hey finally figured out the issue.. I hadn't wrapped the query in a
"query" format .. and it works ..

curl -XPOST localhost:9200/authors/nested_author/_search -d '
{

  • "query": {** *
  • "nested" : {*
    
  •        "path" : "books",*
    
  •        "score_mode" : "avg",*
    
  •        "query" : {*
    
  •            "bool" : {*
    
  •                "must" : [*
    
  •                        {*
    
  •                            "term": {"books.publisher": "orbit"}*
    
  •                        },*
    
  •                        {*
    
  •                            "term": {"books.genre": "thriller"}*
    
  •                        }*
    
  •                ]*
    
  •            }*
    
  •        }*
    
  •    }*
    
  •   }*
    
  •    }'*
    

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 5:46 PM, Manoj Mohan ma...@intelligrape.comwrote:

Thanks Damien.
*
*
It seems to work now with a Nested Filter. I had tried it out earlier
before asking this question in the Elasticsearch HEAD pluginhttp://mobz.github.io/elasticsearch-head/,
but it seemed to fail using the GET call. I now tried it out using a POST
call for which it seems to work. Using the CURL command it works for both
scenarios.

I then tried out using the Nested Query for which I can't seem to make
it work
. Here's a mapping of the index against which I am trying it
out..

  • mappings: {
    • nested_author: {
      • properties: {
        • books: {
          • properties: {
            • genre: {
              • type: string
                }
            • name: {
              • type: string
                }
            • publisher: {
              • type: string
                }
                }
          • type: nested
            }
        • name: {
          • type: string
            }
            }
            }
            }

Some test data ...

curl -XPUT localhost:9200/authors/nested_author/1 -d'{
"name": "Multi G. Enre",
"books": [
{

  • "name": "Guns and lasers",*

  • "genre": "scifi",*

  • "publisher": "orbit"*
    },
    {

  • "name": "Dead in the night",*

  • "genre": "thriller",*

  • "publisher": "penguin"*
    }
    ]
    }'

curl -XPUT localhost:9200/authors/nested_author/2 -d'{
"name": "Alastair Reynolds",
"books": [
{

  • "name": "Revelation Space",*
  • "genre": "scifi",*
  • "publisher": "penguin"*
    }
    ]
    }'

I made this query to search for records, but it results in a *
SearchPhaseExecutionException*

curl -XPOST localhost:9200/authors/nested_author/_search -d '
{

  •        "nested" : {*
    
  •        "path" : "books",*
    
  •        "score_mode" : "avg",*
    
  •        "query" : {*
    
  •            "bool" : {*
    
  •                "must" : [*
    
  •                        {*
    
  •                            "term": {"books.publisher": "orbit"}*
    
  •                        },*
    
  •                        {*
    
  •                            "term": {"books.genre": "thriller"}*
    
  •                        }*
    
  •                ]*
    
  •            }*
    
  •        }*
    
  •    }*
    
  •    }'*
    

Can you spot any issues with the query or the mapping itself for which
the query might be failing ???

Thanks again.. You have been of great help.

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 3:25 PM, Damien Alexandre dalex...@jolicode.comwrote:

On Tuesday, August 6, 2013 11:51:33 AM UTC+2, Manoj Mohan wrote:

Thanks for the reply Damien.

But the problem with nested objects is that there can be a cross match
that results in a fake result as mentioned in this doc
http://www.elasticsearch.org/guide/reference/mapping/nes
ted-type/http://www.elasticsearch.org/guide/reference/mapping/nested-type/
.
So a product having 2 variations -

Price : $50
Color:Blue

Price: $20
Color:Black

Here searching for a Blue colored product under $30 would give back
the product having the above variations, which is a big problem there isn't
a variation that matches the criteria.

This can be avoid using NestedQuery: http://www.**
Elasticsearch Platform — Find real-time answers at scale | Elastichttp://www.elasticsearch.org/guide/reference/query-dsl/nested-query/(or filter).
I use them a lot and that works fine for this case.

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 1:56 PM, Damien Alexandre <
dalex...@jolicode.com> wrote:

From my POV: stay away from has_child and has_parent query if you
need facets - that can't work: you will not be able to perform "color"
facet if the field is not on the product document.

My best guest whould be that the product document should host his
variations (maybe in a nested objecthttp://www.elasticsearch.org/guide/reference/mapping/nested-type/to ease the query against some variation only).

Having everything in the same doc will also ease indexing & update &
query against everything.

My 2cts :wink:
Damien

On Tuesday, July 30, 2013 11:56:56 AM UTC+2, Manoj Mohan wrote:

Hi,

I am working on an application that uses Elasticsearch for providing
a searching across the application. Now I have a scenario where a Product
can have many variations depending on it's colors. So a product A available
in Blue and Green will have 2 Product variations and a Product entity
indexed into ES. Now each of the product variations will contain some
specific fields not present in the Product domain. Also I have marked the
Product - ProductVariation relationship with a parent-child
relationship(Product being the parent).

Now I have a case of searching for a products using a free text
search. Since I have different fields in those domains, I would have to
search across both the domains. What I would essentially like to have is
that I make a single query to search across a product and it's related
child ProductVariation to get a match Eg: Blue jeans search should search
across both where blue is the color present in ProductVariation and Jeans
is a category in Product. Also I intend to provide filtering/faceting over
these fields.

How would I do a search and across which domain. I am tried out the
has_child and has_parent queries but am a bit skeptical about the results.

Any help would be greatly appreciated.

Regards
Manoj Mohan

--
You received this message because you are subscribed to a topic in
the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/**
to**pic/elasticsearch/Y-**AxvhSyhXU/**unsubscribehttps://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe
.
To unsubscribe from this group and all its topics, 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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/**
topic/elasticsearch/Y-**AxvhSyhXU/unsubscribehttps://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe
.
To unsubscribe from this group and all its topics, 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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe.
To unsubscribe from this group and all its topics, 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.

In continuation of this scenario ... it seems that when I get a match over
a document, I would not be able to ascertain which nested documents matched
the original query. I thought the Highlighting API might help out here ..
but it seems that highlighting is not possible with a nested query over
nested objects. Is it so ??
Is there any other way out here ... ??

On the other hand in a Parent-Child scenario, if I query on the Child
domain to get child documents, is it possible to get a list of child
documents pertaining to 'n' no of parent documents.
Eg: If I query of a ProductVariation , is it possible to get those
ProductVariations which are children of 10 Product documents. This is
important in the case of pagination for us.

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 9:06 PM, Manoj Mohan manoj@intelligrape.com wrote:

Hey this extension's pretty cool ... the autocomplete alone makes it
worthwhile..
Thanks a ton

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 6:20 PM, Damien Alexandre dalexandre@jolicode.comwrote:

Haha yes the missing "query" part is a common mistake :slight_smile:

Also, I also recommand
https://chrome.google.com/webstore/detail/sense/doinijnbnggojdlcjifpdckfokbbfpboto write test queries,
it has autocomplete and validation.

Glad I helped you,
Damien

On Tuesday, August 6, 2013 2:36:18 PM UTC+2, Manoj Mohan wrote:

Hey finally figured out the issue.. I hadn't wrapped the query in a
"query" format .. and it works ..

curl -XPOST localhost:9200/authors/nested_author/_search -d '
{

  • "query": {** *
  • "nested" : {*
    
  •        "path" : "books",*
    
  •        "score_mode" : "avg",*
    
  •        "query" : {*
    
  •            "bool" : {*
    
  •                "must" : [*
    
  •                        {*
    
  •                            "term": {"books.publisher": "orbit"}*
    
  •                        },*
    
  •                        {*
    
  •                            "term": {"books.genre": "thriller"}*
    
  •                        }*
    
  •                ]*
    
  •            }*
    
  •        }*
    
  •    }*
    
  •   }*
    
  •    }'*
    

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 5:46 PM, Manoj Mohan ma...@intelligrape.comwrote:

Thanks Damien.
*
*
It seems to work now with a Nested Filter. I had tried it out
earlier before asking this question in the Elasticsearch HEAD pluginhttp://mobz.github.io/elasticsearch-head/,
but it seemed to fail using the GET call. I now tried it out using a POST
call for which it seems to work. Using the CURL command it works for both
scenarios.

I then tried out using the Nested Query for which I can't seem to make
it work
. Here's a mapping of the index against which I am trying it
out..

  • mappings: {
    • nested_author: {
      • properties: {
        • books: {
          • properties: {
            • genre: {
              • type: string
                }
            • name: {
              • type: string
                }
            • publisher: {
              • type: string
                }
                }
          • type: nested
            }
        • name: {
          • type: string
            }
            }
            }
            }

Some test data ...

curl -XPUT localhost:9200/authors/nested_author/1 -d'{
"name": "Multi G. Enre",
"books": [
{

  • "name": "Guns and lasers",*

  • "genre": "scifi",*

  • "publisher": "orbit"*
    },
    {

  • "name": "Dead in the night",*

  • "genre": "thriller",*

  • "publisher": "penguin"*
    }
    ]
    }'

curl -XPUT localhost:9200/authors/nested_author/2 -d'{
"name": "Alastair Reynolds",
"books": [
{

  • "name": "Revelation Space",*
  • "genre": "scifi",*
  • "publisher": "penguin"*
    }
    ]
    }'

I made this query to search for records, but it results in a *
SearchPhaseExecutionException*

curl -XPOST localhost:9200/authors/nested_author/_search -d '
{

  •        "nested" : {*
    
  •        "path" : "books",*
    
  •        "score_mode" : "avg",*
    
  •        "query" : {*
    
  •            "bool" : {*
    
  •                "must" : [*
    
  •                        {*
    
  •                            "term": {"books.publisher": "orbit"}*
    
  •                        },*
    
  •                        {*
    
  •                            "term": {"books.genre": "thriller"}*
    
  •                        }*
    
  •                ]*
    
  •            }*
    
  •        }*
    
  •    }*
    
  •    }'*
    

Can you spot any issues with the query or the mapping itself for which
the query might be failing ???

Thanks again.. You have been of great help.

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 3:25 PM, Damien Alexandre <dalex...@jolicode.com

wrote:

On Tuesday, August 6, 2013 11:51:33 AM UTC+2, Manoj Mohan wrote:

Thanks for the reply Damien.

But the problem with nested objects is that there can be a cross
match that results in a fake result as mentioned in this doc
http://www.elasticsearch.org/guide/reference/mapping/nes
ted-type/http://www.elasticsearch.org/guide/reference/mapping/nested-type/
.
So a product having 2 variations -

Price : $50
Color:Blue

Price: $20
Color:Black

Here searching for a Blue colored product under $30 would give back
the product having the above variations, which is a big problem there isn't
a variation that matches the criteria.

This can be avoid using NestedQuery: http://www.**
Elasticsearch Platform — Find real-time answers at scale | Elastichttp://www.elasticsearch.org/guide/reference/query-dsl/nested-query/(or filter).
I use them a lot and that works fine for this case.

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 1:56 PM, Damien Alexandre <
dalex...@jolicode.com> wrote:

From my POV: stay away from has_child and has_parent query if you
need facets - that can't work: you will not be able to perform "color"
facet if the field is not on the product document.

My best guest whould be that the product document should host his
variations (maybe in a nested objecthttp://www.elasticsearch.org/guide/reference/mapping/nested-type/to ease the query against some variation only).

Having everything in the same doc will also ease indexing & update &
query against everything.

My 2cts :wink:
Damien

On Tuesday, July 30, 2013 11:56:56 AM UTC+2, Manoj Mohan wrote:

Hi,

I am working on an application that uses Elasticsearch for
providing a searching across the application. Now I have a scenario where a
Product can have many variations depending on it's colors. So a product A
available in Blue and Green will have 2 Product variations and a Product
entity indexed into ES. Now each of the product variations will contain
some specific fields not present in the Product domain. Also I have marked
the Product - ProductVariation relationship with a parent-child
relationship(Product being the parent).

Now I have a case of searching for a products using a free text
search. Since I have different fields in those domains, I would have to
search across both the domains. What I would essentially like to have is
that I make a single query to search across a product and it's related
child ProductVariation to get a match Eg: Blue jeans search should search
across both where blue is the color present in ProductVariation and Jeans
is a category in Product. Also I intend to provide filtering/faceting over
these fields.

How would I do a search and across which domain. I am tried out the
has_child and has_parent queries but am a bit skeptical about the results.

Any help would be greatly appreciated.

Regards
Manoj Mohan

--
You received this message because you are subscribed to a topic in
the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/**
to**pic/elasticsearch/Y-**AxvhSyhXU/**unsubscribehttps://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe
.
To unsubscribe from this group and all its topics, 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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/**
topic/elasticsearch/Y-**AxvhSyhXU/unsubscribehttps://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe
.
To unsubscribe from this group and all its topics, 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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe.
To unsubscribe from this group and all its topics, 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.

Yes, I have similar issues and so would would be interested in an answer to
these points

On Wednesday, 7 August 2013 10:32:10 UTC+1, Manoj Mohan wrote:

In continuation of this scenario ... it seems that when I get a match over
a document, I would not be able to ascertain which nested documents matched
the original query. I thought the Highlighting API might help out here ..
but it seems that highlighting is not possible with a nested query over
nested objects. Is it so ??
Is there any other way out here ... ??

On the other hand in a Parent-Child scenario, if I query on the Child
domain to get child documents, is it possible to get a list of child
documents pertaining to 'n' no of parent documents.
Eg: If I query of a ProductVariation , is it possible to get those
ProductVariations which are children of 10 Product documents. This is
important in the case of pagination for us.

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 9:06 PM, Manoj Mohan <ma...@intelligrape.com<javascript:>

wrote:

Hey this extension's pretty cool ... the autocomplete alone makes it
worthwhile..
Thanks a ton

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 6:20 PM, Damien Alexandre <dalex...@jolicode.com<javascript:>

wrote:

Haha yes the missing "query" part is a common mistake :slight_smile:

Also, I also recommand
https://chrome.google.com/webstore/detail/sense/doinijnbnggojdlcjifpdckfokbbfpboto write test queries,
it has autocomplete and validation.

Glad I helped you,
Damien

On Tuesday, August 6, 2013 2:36:18 PM UTC+2, Manoj Mohan wrote:

Hey finally figured out the issue.. I hadn't wrapped the query in a
"query" format .. and it works ..

curl -XPOST localhost:9200/authors/nested_author/_search -d '
{

  • "query": {** *
  • "nested" : {*
    
  •        "path" : "books",*
    
  •        "score_mode" : "avg",*
    
  •        "query" : {*
    
  •            "bool" : {*
    
  •                "must" : [*
    
  •                        {*
    
  •                            "term": {"books.publisher": "orbit"}*
    
  •                        },*
    
  •                        {*
    
  •                            "term": {"books.genre": "thriller"}*
    
  •                        }*
    
  •                ]*
    
  •            }*
    
  •        }*
    
  •    }*
    
  •   }*
    
  •    }'*
    

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 5:46 PM, Manoj Mohan ma...@intelligrape.comwrote:

Thanks Damien.
*
*
It seems to work now with a Nested Filter. I had tried it out
earlier before asking this question in the Elasticsearch HEAD pluginhttp://mobz.github.io/elasticsearch-head/,
but it seemed to fail using the GET call. I now tried it out using a POST
call for which it seems to work. Using the CURL command it works for both
scenarios.

I then tried out using the Nested Query for which I can't seem to
make it work. Here's a mapping of the index against which I am
trying it out..

  • mappings: {
    • nested_author: {
      • properties: {
        • books: {
          • properties: {
            • genre: {
              • type: string
                }
            • name: {
              • type: string
                }
            • publisher: {
              • type: string
                }
                }
          • type: nested
            }
        • name: {
          • type: string
            }
            }
            }
            }

Some test data ...

curl -XPUT localhost:9200/authors/nested_author/1 -d'{
"name": "Multi G. Enre",
"books": [
{

  • "name": "Guns and lasers",*

  • "genre": "scifi",*

  • "publisher": "orbit"*
    },
    {

  • "name": "Dead in the night",*

  • "genre": "thriller",*

  • "publisher": "penguin"*
    }
    ]
    }'

curl -XPUT localhost:9200/authors/nested_author/2 -d'{
"name": "Alastair Reynolds",
"books": [
{

  • "name": "Revelation Space",*
  • "genre": "scifi",*
  • "publisher": "penguin"*
    }
    ]
    }'

I made this query to search for records, but it results in a *
SearchPhaseExecutionException*

curl -XPOST localhost:9200/authors/nested_author/_search -d '
{

  •        "nested" : {*
    
  •        "path" : "books",*
    
  •        "score_mode" : "avg",*
    
  •        "query" : {*
    
  •            "bool" : {*
    
  •                "must" : [*
    
  •                        {*
    
  •                            "term": {"books.publisher": "orbit"}*
    
  •                        },*
    
  •                        {*
    
  •                            "term": {"books.genre": "thriller"}*
    
  •                        }*
    
  •                ]*
    
  •            }*
    
  •        }*
    
  •    }*
    
  •    }'*
    

Can you spot any issues with the query or the mapping itself for which
the query might be failing ???

Thanks again.. You have been of great help.

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 3:25 PM, Damien Alexandre <
dalex...@jolicode.com> wrote:

On Tuesday, August 6, 2013 11:51:33 AM UTC+2, Manoj Mohan wrote:

Thanks for the reply Damien.

But the problem with nested objects is that there can be a cross
match that results in a fake result as mentioned in this doc
http://www.elasticsearch.org/guide/reference/mapping/nes
ted-type/http://www.elasticsearch.org/guide/reference/mapping/nested-type/
.
So a product having 2 variations -

Price : $50
Color:Blue

Price: $20
Color:Black

Here searching for a Blue colored product under $30 would give back
the product having the above variations, which is a big problem there isn't
a variation that matches the criteria.

This can be avoid using NestedQuery: http://www.**
Elasticsearch Platform — Find real-time answers at scale | Elastichttp://www.elasticsearch.org/guide/reference/query-dsl/nested-query/(or filter).
I use them a lot and that works fine for this case.

Regards
Manoj Mohan
Intelligrape Software

On Tue, Aug 6, 2013 at 1:56 PM, Damien Alexandre <
dalex...@jolicode.com> wrote:

From my POV: stay away from has_child and has_parent query if you
need facets - that can't work: you will not be able to perform "color"
facet if the field is not on the product document.

My best guest whould be that the product document should host his
variations (maybe in a nested objecthttp://www.elasticsearch.org/guide/reference/mapping/nested-type/to ease the query against some variation only).

Having everything in the same doc will also ease indexing & update
& query against everything.

My 2cts :wink:
Damien

On Tuesday, July 30, 2013 11:56:56 AM UTC+2, Manoj Mohan wrote:

Hi,

I am working on an application that uses Elasticsearch for
providing a searching across the application. Now I have a scenario where a
Product can have many variations depending on it's colors. So a product A
available in Blue and Green will have 2 Product variations and a Product
entity indexed into ES. Now each of the product variations will contain
some specific fields not present in the Product domain. Also I have marked
the Product - ProductVariation relationship with a parent-child
relationship(Product being the parent).

Now I have a case of searching for a products using a free text
search. Since I have different fields in those domains, I would have to
search across both the domains. What I would essentially like to have is
that I make a single query to search across a product and it's related
child ProductVariation to get a match Eg: Blue jeans search should search
across both where blue is the color present in ProductVariation and Jeans
is a category in Product. Also I intend to provide filtering/faceting over
these fields.

How would I do a search and across which domain. I am tried out
the has_child and has_parent queries but am a bit skeptical about the
results.

Any help would be greatly appreciated.

Regards
Manoj Mohan

--
You received this message because you are subscribed to a topic in
the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/*
*to**pic/elasticsearch/Y-**AxvhSyhXU/**unsubscribehttps://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe
.
To unsubscribe from this group and all its topics, 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 a topic in
the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/**
topic/elasticsearch/Y-**AxvhSyhXU/unsubscribehttps://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe
.
To unsubscribe from this group and all its topics, 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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Y-AxvhSyhXU/unsubscribe.
To unsubscribe from this group and all its topics, 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.