Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Highlighting in nested document #153

Open
bjorn-ali-goransson opened this issue Sep 1, 2015 · 4 comments
Open

Highlighting in nested document #153

bjorn-ali-goransson opened this issue Sep 1, 2015 · 4 comments
Labels

Comments

@bjorn-ali-goransson
Copy link
Contributor

This search query only highlights the document with the non-nested property (but matches both documents), am I missing something?

DELETE /test-1

POST /test-1
{
  "mappings": {
    "page": {
      "properties": {
        "file": {
          "type": "attachment",
          "fields": {
            "title": {
              "store": "yes"
            },
            "file": {
              "term_vector": "with_positions_offsets",
              "store": "yes"
            }
          }
        },
        "obj": {
          "type": "nested",
          "properties": {
            "file": {
              "type": "attachment",
              "fields": {
                "title": {
                  "store": "yes"
                },
                "file": {
                  "term_vector": "with_positions_offsets",
                  "store": "yes"
                }
              }
            }
          }
        }
      }
    }
  }
}

POST /test-1/page/1
{
  "obj": {
    "file": "e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZGVmZjBcbm91aWNvbXBhdFxkZWZsYW5nMTA1M3tcZm9udHRibHtcZjBcZm5pbFxmY2hhcnNldDAgQ2FsaWJyaTt9fQ0Ke1wqXGdlbmVyYXRvciBSaWNoZWQyMCAxMC4wLjEwMjQwfVx2aWV3a2luZDRcdWMxIA0KXHBhcmRcc2EyMDBcc2wyNzZcc2xtdWx0MVxmMFxmczIyXGxhbmcyOSBMb3JlbSBpcHN1bSBkb2xvciBzaXQgYW1ldCBjb25zZWN0ZXR1ciBhZGlwaXNjaW5nIGVsaXRccGFyDQp9DQoA"
  }
}

POST /test-1/page/2
{
  "file": "e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZGVmZjBcbm91aWNvbXBhdFxkZWZsYW5nMTA1M3tcZm9udHRibHtcZjBcZm5pbFxmY2hhcnNldDAgQ2FsaWJyaTt9fQ0Ke1wqXGdlbmVyYXRvciBSaWNoZWQyMCAxMC4wLjEwMjQwfVx2aWV3a2luZDRcdWMxIA0KXHBhcmRcc2EyMDBcc2wyNzZcc2xtdWx0MVxmMFxmczIyXGxhbmcyOSBMb3JlbSBpcHN1bSBkb2xvciBzaXQgYW1ldCBjb25zZWN0ZXR1ciBhZGlwaXNjaW5nIGVsaXRccGFyDQp9DQoA"
}

POST /test-1/page/_search
{
  "query": {
    "query_string": {
      "query": "lorem"
    }
  },
  "highlight" : {
    "fields" : {
      "*" : {}
    }
  }
}
@dadoonet
Copy link
Member

dadoonet commented Sep 1, 2015

I think you need to store in parent. It's a core elasticsearch issue.

Read this elastic/elasticsearch#5245 (comment)

I hope this could work for you. Unsure though.

@bjorn-ali-goransson
Copy link
Contributor Author

Yes, actually include and not store (I think), this does it:

DELETE /test-1

POST /test-1
{
  "mappings": {
    "page": {
      "properties": {
        "file": {
          "type": "attachment",
          "fields": {
            "title": {
              "store": "yes"
            },
            "file": {
              "term_vector": "with_positions_offsets",
              "store": "yes"
            }
          }
        },
        "obj": {
          "type": "nested",
          "include_in_root": true,
          "properties": {
            "file": {
              "type": "attachment",
              "fields": {
                "title": {
                  "store": "yes"
                },
                "file": {
                  "term_vector": "with_positions_offsets",
                  "store": "yes"
                }
              }
            }
          }
        }
      }
    }
  }
}

POST /test-1/page/1
{
  "obj": {
    "file": "e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZGVmZjBcbm91aWNvbXBhdFxkZWZsYW5nMTA1M3tcZm9udHRibHtcZjBcZm5pbFxmY2hhcnNldDAgQ2FsaWJyaTt9fQ0Ke1wqXGdlbmVyYXRvciBSaWNoZWQyMCAxMC4wLjEwMjQwfVx2aWV3a2luZDRcdWMxIA0KXHBhcmRcc2EyMDBcc2wyNzZcc2xtdWx0MVxmMFxmczIyXGxhbmcyOSBMb3JlbSBpcHN1bSBkb2xvciBzaXQgYW1ldCBjb25zZWN0ZXR1ciBhZGlwaXNjaW5nIGVsaXRccGFyDQp9DQoA"
  }
}

POST /test-1/page/2
{
  "file": "e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZGVmZjBcbm91aWNvbXBhdFxkZWZsYW5nMTA1M3tcZm9udHRibHtcZjBcZm5pbFxmY2hhcnNldDAgQ2FsaWJyaTt9fQ0Ke1wqXGdlbmVyYXRvciBSaWNoZWQyMCAxMC4wLjEwMjQwfVx2aWV3a2luZDRcdWMxIA0KXHBhcmRcc2EyMDBcc2wyNzZcc2xtdWx0MVxmMFxmczIyXGxhbmcyOSBMb3JlbSBpcHN1bSBkb2xvciBzaXQgYW1ldCBjb25zZWN0ZXR1ciBhZGlwaXNjaW5nIGVsaXRccGFyDQp9DQoA"
}

POST /test-1/page/_search
{
  "query": {
    "query_string": {
      "query": "lorem"
    }
  },
  "highlight" : {
    "fields" : {
      "*" : {}
    }
  }
}

@dadoonet
Copy link
Member

dadoonet commented Sep 1, 2015

Wanna send a PR to update docs for this?

@bjorn-ali-goransson
Copy link
Contributor Author

Absolutely -- sometime, today.

@dadoonet dadoonet added the doc label Sep 30, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants