{"action":"created","issue":{"url":"https://api.github.com/repos/coralproject/xenia/issues/73","repository_url":"https://api.github.com/repos/coralproject/xenia","labels_url":"https://api.github.com/repos/coralproject/xenia/issues/73/labels{/name}","comments_url":"https://api.github.com/repos/coralproject/xenia/issues/73/comments","events_url":"https://api.github.com/repos/coralproject/xenia/issues/73/events","html_url":"https://github.com/coralproject/xenia/issues/73","id":128586092,"number":73,"title":"Add indexing to query_sets","user":{"login":"jde","id":259957,"avatar_url":"https://avatars.githubusercontent.com/u/259957?v=3","gravatar_id":"","url":"https://api.github.com/users/jde","html_url":"https://github.com/jde","followers_url":"https://api.github.com/users/jde/followers","following_url":"https://api.github.com/users/jde/following{/other_user}","gists_url":"https://api.github.com/users/jde/gists{/gist_id}","starred_url":"https://api.github.com/users/jde/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jde/subscriptions","organizations_url":"https://api.github.com/users/jde/orgs","repos_url":"https://api.github.com/users/jde/repos","events_url":"https://api.github.com/users/jde/events{/privacy}","received_events_url":"https://api.github.com/users/jde/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-01-25T16:57:07Z","updated_at":"2016-02-19T20:05:33Z","closed_at":"2016-02-19T20:05:33Z","body":"__Challenge__: Each query set will require one or more indexes to run efficiently.  \r\n\r\n__Solution__: Add indexing to query_set objects.  The indexes field should accept an array of indexes.  As far as it is possible, the indexes should conform to the [syntax and feature set of mongo itself](https://docs.mongodb.org/manual/reference/method/db.collection.createIndex/#db.collection.createIndex) as opposed to the api of the mgo driver.\r\n\r\n__Notes__\r\n* Users need to understand that creating an index on a large collection is a costly operation that takes time and server resources.  They should also understand the background option.\r\n* Principles of index design should be practiced considering all the indexes across all queries together.  Redundant indexes could hurt write times.\r\n"},"comment":{"url":"https://api.github.com/repos/coralproject/xenia/issues/comments/186382628","html_url":"https://github.com/coralproject/xenia/issues/73#issuecomment-186382628","issue_url":"https://api.github.com/repos/coralproject/xenia/issues/73","id":186382628,"user":{"login":"ardan-bkennedy","id":2280005,"avatar_url":"https://avatars.githubusercontent.com/u/2280005?v=3","gravatar_id":"","url":"https://api.github.com/users/ardan-bkennedy","html_url":"https://github.com/ardan-bkennedy","followers_url":"https://api.github.com/users/ardan-bkennedy/followers","following_url":"https://api.github.com/users/ardan-bkennedy/following{/other_user}","gists_url":"https://api.github.com/users/ardan-bkennedy/gists{/gist_id}","starred_url":"https://api.github.com/users/ardan-bkennedy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ardan-bkennedy/subscriptions","organizations_url":"https://api.github.com/users/ardan-bkennedy/orgs","repos_url":"https://api.github.com/users/ardan-bkennedy/repos","events_url":"https://api.github.com/users/ardan-bkennedy/events{/privacy}","received_events_url":"https://api.github.com/users/ardan-bkennedy/received_events","type":"User","site_admin":false},"created_at":"2016-02-19T20:05:33Z","updated_at":"2016-02-19T20:05:33Z","body":"Indexes have been added to the query set\r\n```\r\n{\r\n   \"name\":\"QTEST_O_basic\",\r\n   \"desc\":\"\",\r\n   \"enabled\":true,\r\n   \"params\":[],\r\n   \"queries\":[\r\n      {\r\n         \"name\":\"Basic\",\r\n         \"type\":\"pipeline\",\r\n         \"collection\":\"test_xenia_data\",\r\n         \"return\":true,\r\n\t\t \"indexes\": [\r\n\t\t\t{\"key\": [\"station_id\"], \"unique\": true} \r\n\t\t ],\r\n         \"commands\":[\r\n            {\"$match\": {\"station_id\" : \"42021\"}},\r\n            {\"$project\": {\"_id\": 0, \"name\": 1}}\r\n         ]\r\n      }\r\n   ]\r\n}\r\n```\r\n\r\nThe cli tool under query now has an index command. Supply the set name\r\n```\r\nquery index -n user_advice\r\n```\r\n\r\nA new route as been added to ensure the index as well\r\n```\r\nPUT  :   /1.0/index/:name\r\n```"}}