{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/kibana/issues/9091","repository_url":"https://api.github.com/repos/elastic/kibana","labels_url":"https://api.github.com/repos/elastic/kibana/issues/9091/labels{/name}","comments_url":"https://api.github.com/repos/elastic/kibana/issues/9091/comments","events_url":"https://api.github.com/repos/elastic/kibana/issues/9091/events","html_url":"https://github.com/elastic/kibana/pull/9091","id":189539554,"number":9091,"title":"Only highlight ALL matching fields if query doesn't target specific fields","user":{"login":"lukasolson","id":1178348,"avatar_url":"https://avatars.githubusercontent.com/u/1178348?v=3","gravatar_id":"","url":"https://api.github.com/users/lukasolson","html_url":"https://github.com/lukasolson","followers_url":"https://api.github.com/users/lukasolson/followers","following_url":"https://api.github.com/users/lukasolson/following{/other_user}","gists_url":"https://api.github.com/users/lukasolson/gists{/gist_id}","starred_url":"https://api.github.com/users/lukasolson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukasolson/subscriptions","organizations_url":"https://api.github.com/users/lukasolson/orgs","repos_url":"https://api.github.com/users/lukasolson/repos","events_url":"https://api.github.com/users/lukasolson/events{/privacy}","received_events_url":"https://api.github.com/users/lukasolson/received_events","type":"User","site_admin":false},"labels":[{"id":462135575,"url":"https://api.github.com/repos/elastic/kibana/labels/:Discovery","name":":Discovery","color":"fef2c0","default":false},{"id":486059395,"url":"https://api.github.com/repos/elastic/kibana/labels/v5.2.0","name":"v5.2.0","color":"ffffff","default":false},{"id":351295427,"url":"https://api.github.com/repos/elastic/kibana/labels/v6.0.0","name":"v6.0.0","color":"ffffff","default":false}],"state":"closed","locked":false,"assignee":{"login":"lukasolson","id":1178348,"avatar_url":"https://avatars.githubusercontent.com/u/1178348?v=3","gravatar_id":"","url":"https://api.github.com/users/lukasolson","html_url":"https://github.com/lukasolson","followers_url":"https://api.github.com/users/lukasolson/followers","following_url":"https://api.github.com/users/lukasolson/following{/other_user}","gists_url":"https://api.github.com/users/lukasolson/gists{/gist_id}","starred_url":"https://api.github.com/users/lukasolson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukasolson/subscriptions","organizations_url":"https://api.github.com/users/lukasolson/orgs","repos_url":"https://api.github.com/users/lukasolson/repos","events_url":"https://api.github.com/users/lukasolson/events{/privacy}","received_events_url":"https://api.github.com/users/lukasolson/received_events","type":"User","site_admin":false},"assignees":[{"login":"lukasolson","id":1178348,"avatar_url":"https://avatars.githubusercontent.com/u/1178348?v=3","gravatar_id":"","url":"https://api.github.com/users/lukasolson","html_url":"https://github.com/lukasolson","followers_url":"https://api.github.com/users/lukasolson/followers","following_url":"https://api.github.com/users/lukasolson/following{/other_user}","gists_url":"https://api.github.com/users/lukasolson/gists{/gist_id}","starred_url":"https://api.github.com/users/lukasolson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukasolson/subscriptions","organizations_url":"https://api.github.com/users/lukasolson/orgs","repos_url":"https://api.github.com/users/lukasolson/repos","events_url":"https://api.github.com/users/lukasolson/events{/privacy}","received_events_url":"https://api.github.com/users/lukasolson/received_events","type":"User","site_admin":false}],"milestone":null,"comments":16,"created_at":"2016-11-15T23:38:27Z","updated_at":"2016-12-29T18:01:39Z","closed_at":"2016-12-29T18:01:39Z","pull_request":{"url":"https://api.github.com/repos/elastic/kibana/pulls/9091","html_url":"https://github.com/elastic/kibana/pull/9091","diff_url":"https://github.com/elastic/kibana/pull/9091.diff","patch_url":"https://github.com/elastic/kibana/pull/9091.patch"},"body":"Fixes https://github.com/elastic/kibana/issues/2358.\r\n\r\nFrom the [Elasticsearch highlighting docs](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/search-request-highlighting.html#field-match):\r\n\r\n> `require_field_match` can be set to false which will cause any field to be highlighted regardless of whether the query matched specifically on them. The default behaviour is true, meaning that only fields that hold a query match will be highlighted.\r\n\r\nPrior to this PR, we were setting `require_field_match` to `false` on all requests from discover. As a result, even if you queried specific fields, or added filters that matched specific fields, you would see matches highlighted from fields not specifically queried.\r\n\r\nThis PR changes the behavior such that the `require_field_match` parameter is only set to `false` if the search query is a simple `query_string` query that doesn't target any fields. As a result, if you query specific fields, then the highlighted matches should only apply to the queried fields.\r\n\r\nThis is, in my opinion, a step in the right direction. A couple of notes about this PR:\r\n\r\nThe code that [detects when the query string applies to a specific field](https://github.com/elastic/kibana/compare/master...lukasolson:fix/over-highlighting#diff-b1e7be471202c5be24e13d990666b5e2R491) is quite primitive. It could definitely be improved, as it currently supposes that a query such as `\":foo\"` targets a specific field, even though it doesn't. We could be smarter about this but I think it would require some sort of query parser that could be more complicated than it's worth at this point.\r\n\r\nThere is still a limitation of this implementation: If you have a *filter* that targets a specific field, then do a search query that *doesn't* target a specific field, then it's possible that over-highlighting could still occur.\r\n\r\nFor example, if I have a `geo.dest: \"CN\"` filter, then search for something like `jpg` in the query bar, you could still get highlighting of `CN` under other matching fields, such as `geo.src`. However, matches of `jpg` would still be highlighted, regardless of field.\r\n\r\nThe alternative is to have additional logic that checks if there are any filters that target specific fields, and if there are, then to not set `require_field_match` to `false`. However, this could have the side effect of under-highlighting; in the same scenario above, this would mean that no matches of `jpg` would be highlighted, since no field was specified. I am personally of the opinion that the former is a better trade-off, but I'm open to discussing this."},"comment":{"url":"https://api.github.com/repos/elastic/kibana/issues/comments/269668372","html_url":"https://github.com/elastic/kibana/pull/9091#issuecomment-269668372","issue_url":"https://api.github.com/repos/elastic/kibana/issues/9091","id":269668372,"user":{"login":"lukasolson","id":1178348,"avatar_url":"https://avatars.githubusercontent.com/u/1178348?v=3","gravatar_id":"","url":"https://api.github.com/users/lukasolson","html_url":"https://github.com/lukasolson","followers_url":"https://api.github.com/users/lukasolson/followers","following_url":"https://api.github.com/users/lukasolson/following{/other_user}","gists_url":"https://api.github.com/users/lukasolson/gists{/gist_id}","starred_url":"https://api.github.com/users/lukasolson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukasolson/subscriptions","organizations_url":"https://api.github.com/users/lukasolson/orgs","repos_url":"https://api.github.com/users/lukasolson/repos","events_url":"https://api.github.com/users/lukasolson/events{/privacy}","received_events_url":"https://api.github.com/users/lukasolson/received_events","type":"User","site_admin":false},"created_at":"2016-12-29T18:01:39Z","updated_at":"2016-12-29T18:01:39Z","body":"Replaced by https://github.com/elastic/kibana/pull/9671."}}
{"actor":{"display_login":"lukasolson"}}