{"action":"closed","issue":{"url":"https://api.github.com/repos/bbcarchdev/twine/issues/8","labels_url":"https://api.github.com/repos/bbcarchdev/twine/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/bbcarchdev/twine/issues/8/comments","events_url":"https://api.github.com/repos/bbcarchdev/twine/issues/8/events","html_url":"https://github.com/bbcarchdev/twine/issues/8","id":80483657,"number":8,"title":"index vectors end up empty if one of the source fields is empty","user":{"login":"nevali","id":57397,"avatar_url":"https://avatars.githubusercontent.com/u/57397?v=3","gravatar_id":"","url":"https://api.github.com/users/nevali","html_url":"https://github.com/nevali","followers_url":"https://api.github.com/users/nevali/followers","following_url":"https://api.github.com/users/nevali/following{/other_user}","gists_url":"https://api.github.com/users/nevali/gists{/gist_id}","starred_url":"https://api.github.com/users/nevali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nevali/subscriptions","organizations_url":"https://api.github.com/users/nevali/orgs","repos_url":"https://api.github.com/users/nevali/repos","events_url":"https://api.github.com/users/nevali/events{/privacy}","received_events_url":"https://api.github.com/users/nevali/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bbcarchdev/twine/labels/invalid","name":"invalid","color":"e6e6e6"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-25T10:15:50Z","updated_at":"2015-05-25T10:48:03Z","closed_at":"2015-05-25T10:48:03Z","body":"The current query is:\r\n\r\n```\r\nUPDATE \"index\" SET \"index_en_gb\" = setweight(to_tsvector(coalesce(\"title\" -> 'en-gb', \"title\" -> 'en', \"title\" -> '_')), 'A') ||\r\nsetweight(to_tsvector(coalesce(\"description\" -> 'en-gb', \"description\" -> 'en', \"description\" -> '_')), 'B') WHERE \"id\" = 'cb90e10a13aa42ad82a0d047e56ab2bb';\r\n```\r\n\r\nIf either of `title` or `description` is empty, then `setweight()` ends up returning an empty value (possibly `NULL`), which causes the whole expression to also be empty and so the item is not indexed.\r\n\r\nThe query should instead read:\r\n\r\n```\r\nUPDATE \"index\" SET \"index_en_gb\" = setweight(to_tsvector(coalesce(\"title\" -> 'en-gb', \"title\" -> 'en', \"title\" -> '_', '')), 'A') ||\r\nsetweight(to_tsvector(coalesce(\"description\" -> 'en-gb', \"description\" -> 'en', \"description\" -> '_', '')), 'B') WHERE \"id\" = 'cb90e10a13aa42ad82a0d047e56ab2bb';\r\n```\r\n\r\n(i.e., include an empty *string* in the `coalesce()` call)"}}