{"action":"created","comment":{"url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/pulls/comments/165981023","pull_request_review_id":94000070,"id":165981023,"diff_hunk":"@@ -0,0 +1,86 @@\n+﻿using Lucene.Net.Analysis.Standard;\r\n+using Lucene.Net.Documents;\r\n+using Lucene.Net.Index;\r\n+using Lucene.Net.QueryParsers.Classic;\r\n+using Lucene.Net.Search;\r\n+using Lucene.Net.Search.Similarities;\r\n+using Lucene.Net.Util;\r\n+using System;\r\n+using System.Collections.Generic;\r\n+using System.Net;\r\n+using System.Text;\r\n+using System.Text.Encodings.Web;\r\n+\r\n+namespace Lykke.Service.ClientSearch.Services.FullTextSearch\r\n+{\r\n+    public class SearcherForExistingClients\r\n+    {\r\n+        public static IList<string> Search(string name, DateTime dateOfBirth)\r\n+        {\r\n+            if (String.IsNullOrWhiteSpace(name) || dateOfBirth == DateTime.MinValue)\r\n+            {\r\n+                return null;\r\n+            }\r\n+\r\n+            Lucene.Net.Store.Directory dir = Indexer.IndexDirectory;\r\n+\r\n+            IndexReader reader = DirectoryReader.Open(dir);\r\n+            IndexSearcher searcher = new IndexSearcher(reader);\r\n+\r\n+            name = name.Trim();\r\n+            string beginningToRemove = FullTextSearchCommon.JUMIO_NA + \" \";\r\n+            if (name.StartsWith(beginningToRemove))\r\n+            {\r\n+                name = name.Substring(beginningToRemove.Length);\r\n+            }\r\n+            string endingToRemove = \" \" + FullTextSearchCommon.JUMIO_NA;\r\n+            if (name.EndsWith(endingToRemove))\r\n+            {\r\n+                name = name.Substring(0, name.Length - endingToRemove.Length);\r\n+            }\r\n+\r\n+            name = FullTextSearchCommon.EncodeForIndex(name.ToLower());\r\n+\r\n+            StringBuilder sb = new StringBuilder();\r\n+            if (!String.IsNullOrWhiteSpace(name))\r\n+            {\r\n+                string phrase = $\"{name} {dateOfBirth.ToString(FullTextSearchCommon.DateTimeFormat)}\";\r\n+                sb.Append($\"ClientNameAndDayOfBirth: \\\"{phrase}\\\"\");\r\n+            }\r\n+\r\n+            if (sb.Length == 0)\r\n+            {\r\n+                return null;\r\n+            }\r\n+\r\n+            string queryStr = sb.ToString();\r\n+\r\n+            using (var rAnalyzer = new StandardAnalyzer(LuceneVersion.LUCENE_48))\r\n+            {\r\n+                QueryParser parser = new QueryParser(LuceneVersion.LUCENE_48, \"ClientNameAndDayOfBirth\", rAnalyzer);\r\n+                Query q = parser.Parse(queryStr);\r\n+\r\n+                var collector = TopScoreDocCollector.Create(1000000, true);\r","path":"src/Lykke.Service.ClientSearch.Services/FullTextSearch/SearcherForExistingClients.cs","position":63,"original_position":63,"commit_id":"e420fb4632a38709f322fcb582688897ff7dd73f","original_commit_id":"e420fb4632a38709f322fcb582688897ff7dd73f","user":{"login":"igromyko","id":30295964,"avatar_url":"https://avatars0.githubusercontent.com/u/30295964?v=4","gravatar_id":"","url":"https://api.github.com/users/igromyko","html_url":"https://github.com/igromyko","followers_url":"https://api.github.com/users/igromyko/followers","following_url":"https://api.github.com/users/igromyko/following{/other_user}","gists_url":"https://api.github.com/users/igromyko/gists{/gist_id}","starred_url":"https://api.github.com/users/igromyko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igromyko/subscriptions","organizations_url":"https://api.github.com/users/igromyko/orgs","repos_url":"https://api.github.com/users/igromyko/repos","events_url":"https://api.github.com/users/igromyko/events{/privacy}","received_events_url":"https://api.github.com/users/igromyko/received_events","type":"User","site_admin":false},"body":"Replaced with constants","created_at":"2018-02-05T14:09:34Z","updated_at":"2018-02-05T14:09:35Z","html_url":"https://github.com/LykkeCity/Lykke.Service.ClientSearch/pull/1#discussion_r165981023","pull_request_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/pulls/1","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/pulls/comments/165981023"},"html":{"href":"https://github.com/LykkeCity/Lykke.Service.ClientSearch/pull/1#discussion_r165981023"},"pull_request":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/pulls/1"}},"in_reply_to_id":165699039},"pull_request":{"url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/pulls/1","id":166526516,"html_url":"https://github.com/LykkeCity/Lykke.Service.ClientSearch/pull/1","diff_url":"https://github.com/LykkeCity/Lykke.Service.ClientSearch/pull/1.diff","patch_url":"https://github.com/LykkeCity/Lykke.Service.ClientSearch/pull/1.patch","issue_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/issues/1","number":1,"state":"open","locked":false,"title":"LWDEV-4063-Client-search-service-2","user":{"login":"igromyko","id":30295964,"avatar_url":"https://avatars0.githubusercontent.com/u/30295964?v=4","gravatar_id":"","url":"https://api.github.com/users/igromyko","html_url":"https://github.com/igromyko","followers_url":"https://api.github.com/users/igromyko/followers","following_url":"https://api.github.com/users/igromyko/following{/other_user}","gists_url":"https://api.github.com/users/igromyko/gists{/gist_id}","starred_url":"https://api.github.com/users/igromyko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igromyko/subscriptions","organizations_url":"https://api.github.com/users/igromyko/orgs","repos_url":"https://api.github.com/users/igromyko/repos","events_url":"https://api.github.com/users/igromyko/events{/privacy}","received_events_url":"https://api.github.com/users/igromyko/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-02-01T12:41:25Z","updated_at":"2018-02-05T14:09:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2fc815ea3bc1896a3f4b408e232fb6e7efe1c38c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/pulls/1/commits","review_comments_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/pulls/1/comments","review_comment_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/issues/1/comments","statuses_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/statuses/e420fb4632a38709f322fcb582688897ff7dd73f","head":{"label":"LykkeCity:dev","ref":"dev","sha":"e420fb4632a38709f322fcb582688897ff7dd73f","user":{"login":"LykkeCity","id":14153330,"avatar_url":"https://avatars0.githubusercontent.com/u/14153330?v=4","gravatar_id":"","url":"https://api.github.com/users/LykkeCity","html_url":"https://github.com/LykkeCity","followers_url":"https://api.github.com/users/LykkeCity/followers","following_url":"https://api.github.com/users/LykkeCity/following{/other_user}","gists_url":"https://api.github.com/users/LykkeCity/gists{/gist_id}","starred_url":"https://api.github.com/users/LykkeCity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LykkeCity/subscriptions","organizations_url":"https://api.github.com/users/LykkeCity/orgs","repos_url":"https://api.github.com/users/LykkeCity/repos","events_url":"https://api.github.com/users/LykkeCity/events{/privacy}","received_events_url":"https://api.github.com/users/LykkeCity/received_events","type":"Organization","site_admin":false},"repo":{"id":97596697,"name":"Lykke.Service.ClientSearch","full_name":"LykkeCity/Lykke.Service.ClientSearch","owner":{"login":"LykkeCity","id":14153330,"avatar_url":"https://avatars0.githubusercontent.com/u/14153330?v=4","gravatar_id":"","url":"https://api.github.com/users/LykkeCity","html_url":"https://github.com/LykkeCity","followers_url":"https://api.github.com/users/LykkeCity/followers","following_url":"https://api.github.com/users/LykkeCity/following{/other_user}","gists_url":"https://api.github.com/users/LykkeCity/gists{/gist_id}","starred_url":"https://api.github.com/users/LykkeCity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LykkeCity/subscriptions","organizations_url":"https://api.github.com/users/LykkeCity/orgs","repos_url":"https://api.github.com/users/LykkeCity/repos","events_url":"https://api.github.com/users/LykkeCity/events{/privacy}","received_events_url":"https://api.github.com/users/LykkeCity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LykkeCity/Lykke.Service.ClientSearch","description":null,"fork":false,"url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch","forks_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/forks","keys_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/teams","hooks_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/hooks","issue_events_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/issues/events{/number}","events_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/events","assignees_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/assignees{/user}","branches_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/branches{/branch}","tags_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/tags","blobs_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/statuses/{sha}","languages_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/languages","stargazers_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/stargazers","contributors_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/contributors","subscribers_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/subscribers","subscription_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/subscription","commits_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/contents/{+path}","compare_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/merges","archive_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/downloads","issues_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/issues{/number}","pulls_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/pulls{/number}","milestones_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/milestones{/number}","notifications_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/labels{/name}","releases_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/releases{/id}","deployments_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/deployments","created_at":"2017-07-18T12:42:28Z","updated_at":"2018-02-01T11:50:04Z","pushed_at":"2018-02-01T12:41:26Z","git_url":"git://github.com/LykkeCity/Lykke.Service.ClientSearch.git","ssh_url":"git@github.com:LykkeCity/Lykke.Service.ClientSearch.git","clone_url":"https://github.com/LykkeCity/Lykke.Service.ClientSearch.git","svn_url":"https://github.com/LykkeCity/Lykke.Service.ClientSearch","homepage":null,"size":76,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"LykkeCity:test","ref":"test","sha":"29e2fad9d01e8f4b14891ee79f31f6614701e935","user":{"login":"LykkeCity","id":14153330,"avatar_url":"https://avatars0.githubusercontent.com/u/14153330?v=4","gravatar_id":"","url":"https://api.github.com/users/LykkeCity","html_url":"https://github.com/LykkeCity","followers_url":"https://api.github.com/users/LykkeCity/followers","following_url":"https://api.github.com/users/LykkeCity/following{/other_user}","gists_url":"https://api.github.com/users/LykkeCity/gists{/gist_id}","starred_url":"https://api.github.com/users/LykkeCity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LykkeCity/subscriptions","organizations_url":"https://api.github.com/users/LykkeCity/orgs","repos_url":"https://api.github.com/users/LykkeCity/repos","events_url":"https://api.github.com/users/LykkeCity/events{/privacy}","received_events_url":"https://api.github.com/users/LykkeCity/received_events","type":"Organization","site_admin":false},"repo":{"id":97596697,"name":"Lykke.Service.ClientSearch","full_name":"LykkeCity/Lykke.Service.ClientSearch","owner":{"login":"LykkeCity","id":14153330,"avatar_url":"https://avatars0.githubusercontent.com/u/14153330?v=4","gravatar_id":"","url":"https://api.github.com/users/LykkeCity","html_url":"https://github.com/LykkeCity","followers_url":"https://api.github.com/users/LykkeCity/followers","following_url":"https://api.github.com/users/LykkeCity/following{/other_user}","gists_url":"https://api.github.com/users/LykkeCity/gists{/gist_id}","starred_url":"https://api.github.com/users/LykkeCity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LykkeCity/subscriptions","organizations_url":"https://api.github.com/users/LykkeCity/orgs","repos_url":"https://api.github.com/users/LykkeCity/repos","events_url":"https://api.github.com/users/LykkeCity/events{/privacy}","received_events_url":"https://api.github.com/users/LykkeCity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LykkeCity/Lykke.Service.ClientSearch","description":null,"fork":false,"url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch","forks_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/forks","keys_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/teams","hooks_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/hooks","issue_events_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/issues/events{/number}","events_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/events","assignees_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/assignees{/user}","branches_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/branches{/branch}","tags_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/tags","blobs_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/statuses/{sha}","languages_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/languages","stargazers_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/stargazers","contributors_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/contributors","subscribers_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/subscribers","subscription_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/subscription","commits_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/contents/{+path}","compare_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/merges","archive_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/downloads","issues_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/issues{/number}","pulls_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/pulls{/number}","milestones_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/milestones{/number}","notifications_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/labels{/name}","releases_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/releases{/id}","deployments_url":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/deployments","created_at":"2017-07-18T12:42:28Z","updated_at":"2018-02-01T11:50:04Z","pushed_at":"2018-02-01T12:41:26Z","git_url":"git://github.com/LykkeCity/Lykke.Service.ClientSearch.git","ssh_url":"git@github.com:LykkeCity/Lykke.Service.ClientSearch.git","clone_url":"https://github.com/LykkeCity/Lykke.Service.ClientSearch.git","svn_url":"https://github.com/LykkeCity/Lykke.Service.ClientSearch","homepage":null,"size":76,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/pulls/1"},"html":{"href":"https://github.com/LykkeCity/Lykke.Service.ClientSearch/pull/1"},"issue":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/issues/1"},"comments":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/LykkeCity/Lykke.Service.ClientSearch/statuses/e420fb4632a38709f322fcb582688897ff7dd73f"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"igromyko"}}