コード例 #1
0
        public FanficsFromElastic GetByGenreAndSearchTerm(string genre, string searchTerm, int skip, int top)
        {
            if (!(string.IsNullOrEmpty(genre) || string.IsNullOrEmpty(searchTerm)))
            {
                var body = new {
                    query = new {
                        @bool = new {
                            must = new object[]
                            {
                                new {
                                    match = new
                                    {
                                        genrename = genre
                                    }
                                },
                                new {
                                    multi_match = new
                                    {
                                        fields = new[] { "title", "genrename", "username", "description" },
                                        query  = searchTerm
                                    }
                                }
                            }
                        }
                    },

                    from = skip,
                    size = top
                };

                return(_mapper.Map <ResultSetFromElastic, FanficsFromElastic>(_elastic.GetFanficsFromBody(body)));
            }

            return(new FanficsFromElastic());
        }