{"action":"created","issue":{"url":"https://api.github.com/repos/medic/medic-webapp/issues/2257","repository_url":"https://api.github.com/repos/medic/medic-webapp","labels_url":"https://api.github.com/repos/medic/medic-webapp/issues/2257/labels{/name}","comments_url":"https://api.github.com/repos/medic/medic-webapp/issues/2257/comments","events_url":"https://api.github.com/repos/medic/medic-webapp/issues/2257/events","html_url":"https://github.com/medic/medic-webapp/issues/2257","id":151878829,"number":2257,"title":"Make the Search service return more relevant results","user":{"login":"SCdF","id":583851,"avatar_url":"https://avatars.githubusercontent.com/u/583851?v=3","gravatar_id":"","url":"https://api.github.com/users/SCdF","html_url":"https://github.com/SCdF","followers_url":"https://api.github.com/users/SCdF/followers","following_url":"https://api.github.com/users/SCdF/following{/other_user}","gists_url":"https://api.github.com/users/SCdF/gists{/gist_id}","starred_url":"https://api.github.com/users/SCdF/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SCdF/subscriptions","organizations_url":"https://api.github.com/users/SCdF/orgs","repos_url":"https://api.github.com/users/SCdF/repos","events_url":"https://api.github.com/users/SCdF/events{/privacy}","received_events_url":"https://api.github.com/users/SCdF/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/medic/medic-webapp/labels/Technical%20Debt","name":"Technical Debt","color":"7a5887"}],"state":"open","locked":false,"assignee":{"login":"diannakane","id":1675870,"avatar_url":"https://avatars.githubusercontent.com/u/1675870?v=3","gravatar_id":"","url":"https://api.github.com/users/diannakane","html_url":"https://github.com/diannakane","followers_url":"https://api.github.com/users/diannakane/followers","following_url":"https://api.github.com/users/diannakane/following{/other_user}","gists_url":"https://api.github.com/users/diannakane/gists{/gist_id}","starred_url":"https://api.github.com/users/diannakane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diannakane/subscriptions","organizations_url":"https://api.github.com/users/diannakane/orgs","repos_url":"https://api.github.com/users/diannakane/repos","events_url":"https://api.github.com/users/diannakane/events{/privacy}","received_events_url":"https://api.github.com/users/diannakane/received_events","type":"User","site_admin":false},"milestone":null,"comments":8,"created_at":"2016-04-29T14:21:35Z","updated_at":"2016-05-02T18:57:46Z","closed_at":null,"body":"Right now the free-text portion of the search service works querying a view that has an `emit` for every \"token\" of every document (that we care about, i.e. all Contacts). If a token is deemed to be a string it's broken up on space and emitted N times for each of _those_ tokens.\r\n\r\nIt is done this way because we do not impose a particular schema, so there is no \"white list\" of fields that we should be searching.\r\n\r\nThe downside of this is that it often isn't amazing at relevance. It returns _everything_ associated with your particular query.\r\n\r\nThis is particularly obvious that we now use the Search service in dropdowns:\r\n\r\n![image](https://cloud.githubusercontent.com/assets/583851/14918627/e51f6d76-0e1c-11e6-8625-2c27d25b5fbd.png)\r\n\r\nHe's there, just buried:\r\n\r\n![image](https://cloud.githubusercontent.com/assets/583851/14918643/f2f4363e-0e1c-11e6-8cdc-17c69c9bfedf.png)\r\n\r\n**We need to work out how to make Search more relevant.**\r\n\r\n# Options\r\n\r\n## Weighted tokens\r\n\r\nOne idea is to make the view \"weighted\". You would change the view to, for every token, `emit([doc._id, token], 1);`. We would then group by the first key (the document id) and reduce by the value (a 1 for each result).\r\n\r\n## Or something else?\r\n\r\nHowever, I'm not convinced that weighted tokens will necessarily work for us in this case. That algorithm gives preference to documents that contain that value _more_, but that isn't necessarily going to lend itself to more relevance. In the above example all of those probably contain the same number of \"victor\" tokens.\r\n\r\nThere is currently undocumented sneaky hax in there, so you can do this:\r\n\r\n![image](https://cloud.githubusercontent.com/assets/583851/14918892/082d08a4-0e1e-11e6-9a8f-83bd2d13683e.png)\r\n\r\nI wonder if we need to think more in this direction?"},"comment":{"url":"https://api.github.com/repos/medic/medic-webapp/issues/comments/216327722","html_url":"https://github.com/medic/medic-webapp/issues/2257#issuecomment-216327722","issue_url":"https://api.github.com/repos/medic/medic-webapp/issues/2257","id":216327722,"user":{"login":"diannakane","id":1675870,"avatar_url":"https://avatars.githubusercontent.com/u/1675870?v=3","gravatar_id":"","url":"https://api.github.com/users/diannakane","html_url":"https://github.com/diannakane","followers_url":"https://api.github.com/users/diannakane/followers","following_url":"https://api.github.com/users/diannakane/following{/other_user}","gists_url":"https://api.github.com/users/diannakane/gists{/gist_id}","starred_url":"https://api.github.com/users/diannakane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diannakane/subscriptions","organizations_url":"https://api.github.com/users/diannakane/orgs","repos_url":"https://api.github.com/users/diannakane/repos","events_url":"https://api.github.com/users/diannakane/events{/privacy}","received_events_url":"https://api.github.com/users/diannakane/received_events","type":"User","site_admin":false},"created_at":"2016-05-02T18:57:46Z","updated_at":"2016-05-02T18:57:46Z","body":"We could even look at delivering the search results within labeled\nsections, \"names with..\" \"parents name with.\" What other types of tokens\ncould be returned?\n\nWe definitely need to understand more when search is used and what users\nare looking for when they use it. Not immediately low-hanging fruit, in my\nopinion, and should be looked at in conjunction with work on filters, which\nis our other means of finding information you are looking for. Adding to\ndesign investigations.\n\n\n\nOn Sun, May 1, 2016 at 1:43 PM, Gareth Bowen <notifications@github.com>\nwrote:\n\n> @SCdF <https://github.com/SCdF> and I have been talking about ways to\n> make this awesomer. I quite like the deep indexing and advanced search\n> feature and it's something we supported in 0.4 via lucene. I think it's\n> great that right now you can configure contacts to have some arbitrary\n> field that's specific to your deployment and search against it. There are\n> two problems with this currently: performance (which is being covered by\n> other issues), and relevance (this issue).\n>\n> I vote for some investigation into weighted tokens. If we can make the\n> freetext view order based on where the token is found (eg: name is a heavy\n> weighting, parents name is a light weighting) then in this example Victor\n> will show up at the top.\n>\n> —\n> You are receiving this because you were assigned.\n> Reply to this email directly or view it on GitHub\n> <https://github.com/medic/medic-webapp/issues/2257#issuecomment-216070800>\n>\n\n\n\n-- \nP.S. Join our community. Sign up for Medic Mobile's newsletter\n<http://medicmobile.us8.list-manage.com/track/click?u=e5b07d2afb4b273eaff8e3c53&id=a3129fc799&e=c511575255>\n.\n\n\nDianna Kane | Senior Designer\nMedic Mobile <http://www.medicmobile.org/> +1 216 262 2204\n@*M*edic <http://www.twitter.com/medic> Facebook\n<https://www.facebook.com/MedicMobile> @diannakane\n"}}