首页 > 其他 > 详细

写个Elasticsearch的client库简化操作

时间:2015-04-03 19:44:18      阅读:196      评论:0      收藏:0      [点我收藏+]
[TestMethod]
        public void Analyze()
        {
            string[] d = mIndex.Analyze("c# socket", "ik");
        }
        [TestMethod]
        public void match()
        {
            IList<Blog> items = mIndex.Query<Blog>(q => q.Match(new SearchMatch { field = "title", query = "c# socket" }));

        }
        [TestMethod]
        public void querytring()
        {
            IList<Blog> items = mIndex.Query<Blog>(q => q.QueryString(new QueryString { fields = new string[] { "title", "description" }, query = "c# socket" }));
        }
        [TestMethod]
        public void match_all()
        {
            IList<Blog> items = mIndex.Query<Blog>(q => q.Match_all());
        }
        [IndexType("blog")]
        public class Blog
        {
            [ID]
            [Column(Type = ColumnType._string, Store = true, Index = IndexType._not_analyzed)]
            public string id { get; set; }
            [Column(Type = ColumnType._string, indexAnalyzer = "ik", searchAnalyzer = "ik")]
            public string title { get; set; }
            [Column(Type = ColumnType._string, Index = IndexType._no)]
            public string url { get; set; }
            [Column(Type = ColumnType._string)]
            public string author { get; set; }
            [Column(Type = ColumnType._string, indexAnalyzer = "ik", searchAnalyzer = "ik")]
            public string description { get; set; }
            [Column(Type = ColumnType._string, Index = IndexType._no)]
            public string content { get; set; }
            [Column(Type = ColumnType._date, Index = IndexType._not_analyzed)]
            public DateTime createTime { get; set; }
        }



写个Elasticsearch的client库简化操作

原文:http://my.oschina.net/ikende/blog/395843

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!