{"id":21531629,"url":"https://github.com/hwantage/hansearch","last_synced_at":"2025-07-02T03:06:50.978Z","repository":{"id":219517351,"uuid":"749247690","full_name":"hwantage/hansearch","owner":"hwantage","description":"Json객체에서 한글 검색을 수행하는 라이브러리. 한글 초성 검색을 지원한다. Library for performing Korean search within JSON objects. Supports Korean initial consonant search.","archived":false,"fork":false,"pushed_at":"2025-03-03T05:50:58.000Z","size":44,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-14T11:48:55.123Z","etag":null,"topics":["hangul","npm-package","searching-algorithms"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/hangul-search","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hwantage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-28T01:52:10.000Z","updated_at":"2025-06-06T01:58:48.000Z","dependencies_parsed_at":"2024-02-01T16:13:24.653Z","dependency_job_id":"dead47ed-6f0a-4ed5-ad39-08121ced8806","html_url":"https://github.com/hwantage/hansearch","commit_stats":null,"previous_names":["hwantage/hansearch"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hwantage/hansearch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwantage%2Fhansearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwantage%2Fhansearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwantage%2Fhansearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwantage%2Fhansearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hwantage","download_url":"https://codeload.github.com/hwantage/hansearch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwantage%2Fhansearch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263066558,"owners_count":23408387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hangul","npm-package","searching-algorithms"],"created_at":"2024-11-24T02:15:31.774Z","updated_at":"2025-07-02T03:06:50.959Z","avatar_url":"https://github.com/hwantage.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## hansearch\n\nJson객체에서 한글 검색을 수행하는 라이브러리. 한글 초성 검색을 지원합니다.\n\u003cbr/\u003e\nLibrary for performing Korean search within JSON objects. Supports Korean initial consonant search.\n\n[See the simple live demo](https://hwantage.github.io/hansearch/demo/)\n\nHugo 블로그에서 Fuse.js 를 이용해 검색기능을 구현해 보았는데, 한글 검색 지원이 원활하지 않았습니다. json 데이터를 기준으로 검색을 수행하는 라이브러리가 없어 레퍼런스를 참고하여 직접 패키지로 만들었습니다.\n\n- 매우 심플하고 빠릅니다.\n- 영문 대소문자 구분없이 검색을 지원합니다.\n- 한글 초성 검색을 지원합니다.\n- 특수문자에 대한 검색을 지원합니다. (Contributions by [hwahyeon](https://github.com/hwahyeonhttps:/))\n- 사용자 입력 그대로 exact matching 검색이 가능합니다. (mode:\"exact\" 옵션항목 참고)\n- 기본적으로 자음 분해 결합을 통해 사용자의 입력 실수 대응 및 예측 검색을 수행합니다. 예) \"얹\"을 입력한 경우 \"언제나\"가 검색 결과로 도출.\n- 마지막 문자의 홑받침을 다음 문자 검색에 사용합니다. 예) \"국\"을 입력한 경우 \"_국_\" 와 \"_구ㄱ_\"로 검색을 수행.\n- 마지막 문자의 겹받침을 분해하여 다음 문자를 예측 검색 합니다. 예) \"많\" 입력시 \"_많_\", \"_만_\", \"_만ㅎ_\"로 검색을 수행.\n- 겹초성으로 입력된 경우 분해 검색을 수행합니다. 예) ㅍㄻㅌ 입력시 \"_ㅍㄹㅁㅌ_\" 로 검색 수행.\n- Typescript 를 지원하도록 구현하였습니다.\n- AMD, CJS 스펙을 모두 지원할 수 있도록 UMD 패턴으로 작성하였습니다.\n- 사용법이 매우 간편합니다.\n\n[라이브 데모 확인하기](https://hwantage.github.io/hansearch/demo/)\n\n## Usage 1\n\n노드 패키지를 설치해서 테스트 가능합니다. 간편하게 테스트 해보시려면 `Usage 2` 섹션을 참고하세요.\nnpm 패키지로 설치합니다.\n\n```shell\nnpm i hangul-search\n```\n\n코드를 작성합니다.\n\n```js\n// 라이브러리 import\nimport hansearch from \"hangul-search\";\n\n// Json 객체 정의\nvar json = [\n  {\n    title: \"Javascript find, findIndex, filter\",\n    users: [\"김정환\", \"홍길동\", \"강감찬\", \"아이유\"],\n    description: \"구글 네이버 다음\",\n  },\n  {\n    title: \"Javascript 직렬화(serialization)\",\n    users: [\"골리앗\", \"이순신\", \"김길동\"],\n    description: \"직렬화를 알아본다.\",\n  },\n  {\n    title: \"Javascript 템플릿 리터럴(Template literal)\",\n    users: [\"James\", \"Tom\", \"David\"],\n    description: \"고글 가글 고고씽\",\n  },\n];\n\n// 검색 수행\nconst result = hansearch(json, \"ㅈㅀ\");\nconsole.log(result);\n\n/* 출력 결과\n  {\n    \"items\" :\n    [\n      {\n        \"title\": \"Javascript 직렬화(serialization)\",\n        \"users\": [\"골리앗\", \"이순신\", \"김길동\"],\n        \"description\": \"직렬화를 알아본다.\"\n      }\n    ]\n  }\n  */\n```\n\n## Usage 2\n\nCDN을 이용하여 실행가능합니다.\n\n```html\n\u003cscript src=\"https://hwantage.github.io/hansearch/src/index.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n\u003cscript type=\"text/javascript\"\u003e\n  var json = [\n    {\n      title: \"Javascript find, findIndex, filter\",\n      users: [\"김정환\", \"홍길동\", \"강감찬\", \"아이유\"],\n      description: \"구글 네이버 다음\",\n    },\n    {\n      title: \"Javascript 직렬화(serialization)\",\n      users: [\"골리앗\", \"이순신\", \"김길동\"],\n      description: \"직렬화를 알아본다.\",\n    },\n    {\n      title: \"Javascript 템플릿 리터럴(Template literal)\",\n      users: [\"James\", \"Tom\", \"David\"],\n      description: \"고글 가글 고고씽\",\n    },\n  ];\n\n  var result = hansearch(json, \"ㅈㅀ\");\n  console.log(result);\n\n  /* 출력 결과\n  {\n    \"items\" :\n    [\n      {\n        \"title\": \"Javascript 직렬화(serialization)\",\n        \"users\": [\"골리앗\", \"이순신\", \"김길동\"],\n        \"description\": \"직렬화를 알아본다.\"\n      }\n    ]\n  }\n  */\n\u003c/script\u003e\n```\n\n## Options\n\n3번째 인자에 검색 대상 키 컬럼을 지정할 수 있습니다. 값을 지정하지 않으면 모든 키를 대상으로 검색을 수행합니다.\n\n```js\nvar result = hansearch(json, \"ㅈ렬화\"); // 모든 키를 대상으로 검색을 수행합니다.\nvar result = hansearch(json, \"ㅈ렬화\", [\"title\"]); // title 키를 대상으로 검색을 수행합니다.\nvar result = hansearch(json, \"ㅈ렬화\", [\"title\", \"users\"]); // title과 users 키를 대상으로 검색을 수행합니다.\n```\n\n.mark() 메소드 체이닝을 지원합니다. 일치한 검색어를 `\u003cmark\u003e` 태그로 감싸주며, 원하는 태그를 인자로 넘겨줄 수 있습니다.\n\n```js\nvar result = hansearch(json, \"ㅈ렬화\").mark(); // 검색어와 일치한 단어를 \u003cmark\u003e 태그로 감싼 결과를 리턴합니다.\nvar result = hansearch(json, \"ㅈ렬화\").mark(\"tags\"); // 검색어와 일치한 단어를 \u003ctags\u003e 태그로 감싼 결과를 리턴합니다.\n```\n\nhansearch 의 3번째 인자에는 json 형태로 옵션값을 전달할 수도 있습니다.\n\n```js\nvar options = {\n  mode: \"exact\",\n  keys: [\"key1\", \"key2\"],\n};\nvar result = hansearch(json, \"ㅈ렬화\", options);\n```\n\n`mode` string \"exact\" : 정확히 일치하는 검색을 수행합니다. default 는 자음 분해 검색을 수행합니다.\n\n| exact 모드인 경우 \"파라미터\"를 검색하기 위해 \"ㅍㄻㅌ\" 와 같이 입력한 경우 검색이 되지 않습니다. default 모드에서는 ㄻ 을 ㄹㅁ 으로 분해하여 검색을 수행합니다. 특별히 값을 지정하지 않으면 분해 검색을 수행합니다.\n\n`keys` string[] : 검색 대상 키값을 지정합니다. 값을 지정하지 않으면 모든 키를 대상으로 검색을 수행합니다.\n\n| 다음 두 코드는 동일한 동작을 수행합니다.\n\n```js\nvar keys = [\"title\", \"users\"];\nvar options = { keys: [\"title\", \"users\"] };\n\nvar result = hansearch(json, \"ㅈ렬화\", keys);\nvar result = hansearch(json, \"ㅈ렬화\", options);\n```\n\n## References\n\nhttps://gurtn.tistory.com/207\n\nhttps://github.com/hwahyeon/korean-unpacker/issues/1\n\n## LICENSE\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhwantage%2Fhansearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhwantage%2Fhansearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhwantage%2Fhansearch/lists"}