Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A problem involving parent-child documents and using top_hits #28478

Closed
zp-shadowolf opened this issue Feb 1, 2018 · 6 comments
Closed

A problem involving parent-child documents and using top_hits #28478

zp-shadowolf opened this issue Feb 1, 2018 · 6 comments
Labels
feedback_needed :Search/Search Search-related issues that do not fall into other categories

Comments

@zp-shadowolf
Copy link

zp-shadowolf commented Feb 1, 2018

Error Description

Index ptedata designed two documents, the session and user. User for the session's parent document. Two documents have same fields (only save the contents of different), only through an rs_type field to distinguish session or user. When aggs use top_hits return field content, but returned the following error.

Code

GET 45_hot/ptedata/_search
{
  "size": 0,
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "rs_type": {
              "value": "session"
            }
          }
        },
        {
          "range": {
            "v_ymd": {
              "format": "yyyy-MM-dd", 
              "gte": "2017-12-03",
              "lte": "2017-12-03"
            }
          }
        },
        {
          "term": {
            "sid": {
              "value": "45341cfb"
            }
          }
        },
        {
          "nested": {
            "path": "scene",
            "query": {
              "bool": {
                "must": [
                  {
                    "term": {
                      "scene.cutpath": {
                        "value": "https://www.biccamera.com/bc/category/"
                      }
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  },
  "aggs": {
    "pv": {
      "nested": {
        "path": "scene"
      },
      "aggs": {
        "pv2": {
          "filter": {
            "bool": {
              "must": [
                {
                  "term": {
                    "scene.cutpath": "https://www.biccamera.com/bc/category/"
                  }
                }  
              ]
            }
          },
          "aggs": {
            "scr": {
              "nested": {
                "path": "scene.scroll"
              },
              "aggs": {
                "scroll_details": {
                  "top_hits": {
                    "_source": [
                      "scene.scroll.pos",
                      "scene.scroll.vh"
                    ], 
                    "size": 10
                  }
                },
                "scroll_sum": {
                  "filter": {
                    "exists": {
                      "field": "scene.scroll.vh"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Error

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_state_exception",
        "reason": "Child query must not match same docs with parent filter. Combine them as must clauses (+) to find a problem doc. docId=2147483647, class org.apache.lucene.search.TermScorer"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "45_hot",
        "node": "RPzpfc_3RAC2b5n69X8xbA",
        "reason": {
          "type": "illegal_state_exception",
          "reason": "Child query must not match same docs with parent filter. Combine them as must clauses (+) to find a problem doc. docId=2147483647, class org.apache.lucene.search.TermScorer"
        }
      }
    ]
  },
  "status": 500
}

Thank you very much for your help.

@martijnvg
Copy link
Member

@zp-shadowolf Can you tell what ES version you're using?
Do both user and session documents have scene.scroll.* fields and are do they use the same type of field mappings?

This type of error has been reported before and general validation mechanism is needed to prevent this error #23290, but I'm still unsure how this can happen in your case, because in previous reports a nested query was used inside a filter aggregation that was then nested under a nested aggregation.

@zp-shadowolf
Copy link
Author

zp-shadowolf commented Feb 4, 2018

Yes, es now can not use more than one type in the same index, so the user and session are using the same type, using the join method.

@zp-shadowolf
Copy link
Author

@martijnvg

@martijnvg
Copy link
Member

@zp-shadowolf Can you share your mapping or at least the relevant portions of it?

@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Parent/Child labels Feb 14, 2018
@mayya-sharipova
Copy link
Contributor

mayya-sharipova commented Mar 22, 2018

@zp-shadowolf Can you please provide the mappings and ES version or will be closing the issue as we don't have enough feedback.

@colings86
Copy link
Contributor

No further feedback. Closing this issue but if you have the requested information can you share it and we can look at reopening the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback_needed :Search/Search Search-related issues that do not fall into other categories
Projects
None yet
Development

No branches or pull requests

5 participants