{"action":"created","issue":{"url":"https://api.github.com/repos/medcl/elasticsearch-analysis-pinyin/issues/15","labels_url":"https://api.github.com/repos/medcl/elasticsearch-analysis-pinyin/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/medcl/elasticsearch-analysis-pinyin/issues/15/comments","events_url":"https://api.github.com/repos/medcl/elasticsearch-analysis-pinyin/issues/15/events","html_url":"https://github.com/medcl/elasticsearch-analysis-pinyin/issues/15","id":100443067,"number":15,"title":"关于pinyin分词正向搜索","user":{"login":"starckgates","id":12822162,"avatar_url":"https://avatars.githubusercontent.com/u/12822162?v=3","gravatar_id":"","url":"https://api.github.com/users/starckgates","html_url":"https://github.com/starckgates","followers_url":"https://api.github.com/users/starckgates/followers","following_url":"https://api.github.com/users/starckgates/following{/other_user}","gists_url":"https://api.github.com/users/starckgates/gists{/gist_id}","starred_url":"https://api.github.com/users/starckgates/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/starckgates/subscriptions","organizations_url":"https://api.github.com/users/starckgates/orgs","repos_url":"https://api.github.com/users/starckgates/repos","events_url":"https://api.github.com/users/starckgates/events{/privacy}","received_events_url":"https://api.github.com/users/starckgates/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-08-12T00:50:18Z","updated_at":"2015-08-12T02:44:25Z","closed_at":null,"body":"hi，medcl大神，我又来这边看pinyin了，请教您个问题，如果我想要通过pinyin进行正向搜索，应该怎么处理呢？比如，我想搜索  “我们来自中国”  “中国是个大国”，我输入‘zg’ 就会把前面的搜出来，您明白这个意思了吗？就是说我想把正向的内容放在前面，或者是像sql中like zg% 这样的。\r\n\r\n-----------------------------------------\r\n\r\n另外，我分词设置成如下\r\n\r\n---------------------\r\n################################## Pinyin ###################################\r\nindex: \r\n  analysis:\r\n    analyzer:\r\n      pinyin_analyzer:\r\n        tokenizer: my_pinyin\r\n        filter: [standard,nGram]\r\n    tokenizer:\r\n      my_pinyin:\r\n        type: pinyin\r\n        first_letter: \"prifix\"\r\n        padding_char: \" \"\r\n\r\n------------\r\n\r\n映射设置成如下：\r\n\r\n-------------\r\nPOST /tag/keywords/_mapping\r\n{\r\n    \"keywords\": {\r\n        \"properties\": {\r\n            \"kwname\": {\r\n                \"type\": \"multi_field\",\r\n                \"fields\": {\r\n                    \"kwname\": {\r\n                        \"type\": \"string\",\r\n                        \"store\": \"no\",\r\n                        \"term_vector\": \"with_positions_offsets\",\r\n                        \"analyzer\": \"pinyin_analyzer\",\r\n                        \"boost\": 10\r\n                    },\r\n                    \"primitive\": {\r\n                        \"type\": \"string\",\r\n                        \"store\": \"yes\",\r\n                        \"analyzer\": \"keyword\"\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n---------------------\r\nhttp://localhost:9200/tag/_analyze?text=%E5%88%98%E5%BE%B7%E5%8D%8E&analyzer=pinyin_analyzer\r\n\r\n结果是\r\n\r\n-----------\r\n\r\n{\"tokens\":[{\"token\":\"l\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"ld\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"d\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"dh\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"h\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"hl\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"l\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"li\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"i\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"iu\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"u\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"ud\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"d\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"de\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"e\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"eh\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"h\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"hu\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"u\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"ua\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"a\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1}]}\r\n\r\n这个有点太细了，怎么让他粗一些\r\n比如就要\r\n{\"token\":\"liu\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"de\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"hua\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},{\"token\":\"ldh\",\"start_offset\":0,\"end_offset\":3,\"type\":\"word\",\"position\":1},\r\n\r\n应该怎么设置？\r\n\r\n\r\n谢谢大神~~~~~\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/medcl/elasticsearch-analysis-pinyin/issues/comments/130140659","html_url":"https://github.com/medcl/elasticsearch-analysis-pinyin/issues/15#issuecomment-130140659","issue_url":"https://api.github.com/repos/medcl/elasticsearch-analysis-pinyin/issues/15","id":130140659,"user":{"login":"starckgates","id":12822162,"avatar_url":"https://avatars.githubusercontent.com/u/12822162?v=3","gravatar_id":"","url":"https://api.github.com/users/starckgates","html_url":"https://github.com/starckgates","followers_url":"https://api.github.com/users/starckgates/followers","following_url":"https://api.github.com/users/starckgates/following{/other_user}","gists_url":"https://api.github.com/users/starckgates/gists{/gist_id}","starred_url":"https://api.github.com/users/starckgates/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/starckgates/subscriptions","organizations_url":"https://api.github.com/users/starckgates/orgs","repos_url":"https://api.github.com/users/starckgates/repos","events_url":"https://api.github.com/users/starckgates/events{/privacy}","received_events_url":"https://api.github.com/users/starckgates/received_events","type":"User","site_admin":false},"created_at":"2015-08-12T02:44:25Z","updated_at":"2015-08-12T02:44:25Z","body":"嗯，这里面好像一写代码就都靠右对齐了。。。\r\n我试试"}}