{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/6167","repository_url":"https://api.github.com/repos/elastic/elasticsearch","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/6167/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/6167/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/6167/events","html_url":"https://github.com/elastic/elasticsearch/issues/6167","id":33486705,"number":6167,"title":"Weird behaviour with highlighting when using highlight_query. Some field names work while others don't.","user":{"login":"make","id":70431,"avatar_url":"https://avatars.githubusercontent.com/u/70431?v=3","gravatar_id":"","url":"https://api.github.com/users/make","html_url":"https://github.com/make","followers_url":"https://api.github.com/users/make/followers","following_url":"https://api.github.com/users/make/following{/other_user}","gists_url":"https://api.github.com/users/make/gists{/gist_id}","starred_url":"https://api.github.com/users/make/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/make/subscriptions","organizations_url":"https://api.github.com/users/make/orgs","repos_url":"https://api.github.com/users/make/repos","events_url":"https://api.github.com/users/make/events{/privacy}","received_events_url":"https://api.github.com/users/make/received_events","type":"User","site_admin":false},"labels":[{"id":111549183,"url":"https://api.github.com/repos/elastic/elasticsearch/labels/:Highlighting","name":":Highlighting","color":"009800","default":false},{"id":110815527,"url":"https://api.github.com/repos/elastic/elasticsearch/labels/adoptme","name":"adoptme","color":"207de5","default":false},{"id":23173,"url":"https://api.github.com/repos/elastic/elasticsearch/labels/bug","name":"bug","color":"9e2c2c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2014-05-14T12:21:29Z","updated_at":"2016-11-24T18:45:54Z","closed_at":"2016-11-24T18:45:54Z","body":"I noticed a weird highlighting issue when using highlight_query where some fields were not highlighted but others were. For example result highlighting doesn't work with field names like 'firstName', 'fa', 'f0' and 'g0' but works with field names 'f' and 'g' when using also '*' to highlight all fields. See the script below to get clearer image of the issue.\n\nThis occurred at least with elasticsearch-1.1.1.\n\nScript:\n\n```\n#!/bin/bash\nfor fieldName in g g0 f f0; do\n  curl -XDELETE localhost:9200/test\n  curl -XPUT localhost:9200/test/test/1?pretty -d '{\"'\"$fieldName\"'\":\"Content\",\"subdoc\":[{\"title\":\"test document\"}]}'\n  sleep 1\n  curl -XGET localhost:9200/test/test/_search?pretty -d '{\n    \"query\": {\n        \"query_string\" : {\n            \"query\" : \"document AND '\"$fieldName\"':Content\"\n        }\n    },\n    \"highlight\": {\n        \"number_of_fragments\" : 4,\n        \"pre_tags\":[\"<b>\"],\n        \"post_tags\":[\"<\\u002fb>\"],\n        \"fields\":{\n            \"*\":{\n                \"highlight_query\":{\n                    \"match\":{\n                        \"*\":{\n                            \"query\":\"document\"\n                        }\n                    }\n                }\n            },\n            \"'\"$fieldName\"'\":{\n                \"highlight_query\":{\n                    \"match\":{\n                        \"'\"$fieldName\"'\":{\n                            \"query\":\"Content\"\n                        }\n                    }\n                }\n            }\n        }\n    }\n  }'\ndone\n```\n\nOutput:\n\n```\n{\"acknowledged\":true}{\n  \"_index\" : \"test\",\n  \"_type\" : \"test\",\n  \"_id\" : \"1\",\n  \"_version\" : 1,\n  \"created\" : true\n}\n{\n  \"took\" : 3,\n  \"timed_out\" : false,\n  \"_shards\" : {\n    \"total\" : 5,\n    \"successful\" : 5,\n    \"failed\" : 0\n  },\n  \"hits\" : {\n    \"total\" : 1,\n    \"max_score\" : 0.32546654,\n    \"hits\" : [ {\n      \"_index\" : \"test\",\n      \"_type\" : \"test\",\n      \"_id\" : \"1\",\n      \"_score\" : 0.32546654, \"_source\" : {\"g\":\"Content\",\"subdoc\":[{\"title\":\"test document\"}]},\n      \"highlight\" : {\n        \"g\" : [ \"<b>Content</b>\" ],\n        \"subdoc.title\" : [ \"test <b>document</b>\" ]\n      }\n    } ]\n  }\n}\n{\"acknowledged\":true}{\n  \"_index\" : \"test\",\n  \"_type\" : \"test\",\n  \"_id\" : \"1\",\n  \"_version\" : 1,\n  \"created\" : true\n}\n{\n  \"took\" : 2,\n  \"timed_out\" : false,\n  \"_shards\" : {\n    \"total\" : 5,\n    \"successful\" : 5,\n    \"failed\" : 0\n  },\n  \"hits\" : {\n    \"total\" : 1,\n    \"max_score\" : 0.32546654,\n    \"hits\" : [ {\n      \"_index\" : \"test\",\n      \"_type\" : \"test\",\n      \"_id\" : \"1\",\n      \"_score\" : 0.32546654, \"_source\" : {\"g0\":\"Content\",\"subdoc\":[{\"title\":\"test document\"}]},\n      \"highlight\" : {\n        \"subdoc.title\" : [ \"test <b>document</b>\" ]\n      }\n    } ]\n  }\n}\n{\"acknowledged\":true}{\n  \"_index\" : \"test\",\n  \"_type\" : \"test\",\n  \"_id\" : \"1\",\n  \"_version\" : 1,\n  \"created\" : true\n}\n{\n  \"took\" : 4,\n  \"timed_out\" : false,\n  \"_shards\" : {\n    \"total\" : 5,\n    \"successful\" : 5,\n    \"failed\" : 0\n  },\n  \"hits\" : {\n    \"total\" : 1,\n    \"max_score\" : 0.32546654,\n    \"hits\" : [ {\n      \"_index\" : \"test\",\n      \"_type\" : \"test\",\n      \"_id\" : \"1\",\n      \"_score\" : 0.32546654, \"_source\" : {\"f\":\"Content\",\"subdoc\":[{\"title\":\"test document\"}]},\n      \"highlight\" : {\n        \"f\" : [ \"<b>Content</b>\" ],\n        \"subdoc.title\" : [ \"test <b>document</b>\" ]\n      }\n    } ]\n  }\n}\n{\"acknowledged\":true}{\n  \"_index\" : \"test\",\n  \"_type\" : \"test\",\n  \"_id\" : \"1\",\n  \"_version\" : 1,\n  \"created\" : true\n}\n{\n  \"took\" : 4,\n  \"timed_out\" : false,\n  \"_shards\" : {\n    \"total\" : 5,\n    \"successful\" : 5,\n    \"failed\" : 0\n  },\n  \"hits\" : {\n    \"total\" : 1,\n    \"max_score\" : 0.32546654,\n    \"hits\" : [ {\n      \"_index\" : \"test\",\n      \"_type\" : \"test\",\n      \"_id\" : \"1\",\n      \"_score\" : 0.32546654, \"_source\" : {\"f0\":\"Content\",\"subdoc\":[{\"title\":\"test document\"}]},\n      \"highlight\" : {\n        \"subdoc.title\" : [ \"test <b>document</b>\" ]\n      }\n    } ]\n  }\n}\n```\n\nMarkus\n"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/262831181","html_url":"https://github.com/elastic/elasticsearch/issues/6167#issuecomment-262831181","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/6167","id":262831181,"user":{"login":"clintongormley","id":56599,"avatar_url":"https://avatars.githubusercontent.com/u/56599?v=3","gravatar_id":"","url":"https://api.github.com/users/clintongormley","html_url":"https://github.com/clintongormley","followers_url":"https://api.github.com/users/clintongormley/followers","following_url":"https://api.github.com/users/clintongormley/following{/other_user}","gists_url":"https://api.github.com/users/clintongormley/gists{/gist_id}","starred_url":"https://api.github.com/users/clintongormley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clintongormley/subscriptions","organizations_url":"https://api.github.com/users/clintongormley/orgs","repos_url":"https://api.github.com/users/clintongormley/repos","events_url":"https://api.github.com/users/clintongormley/events{/privacy}","received_events_url":"https://api.github.com/users/clintongormley/received_events","type":"User","site_admin":false},"created_at":"2016-11-24T18:45:54Z","updated_at":"2016-11-24T18:45:54Z","body":"Just realised the problem.  The `match` query is for a single field, so it was just matching whichever field came first.  This will no longer match any fields in 5.0"}}
{"actor":{"display_login":"clintongormley"}}