码迷,mamicode.com
首页 > 其他好文 > 详细

写个Elasticsearch的client库简化操作

时间:2015-04-03 19:47:07      阅读:195      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!