예제 #1
0
        public static Tuple <string, string, string, int> getDocument(string searchID)
        {
            string id   = "";
            string name = "";
            string originalVoiceActor = "";
            int    animatedDebut      = 0;

            var response = ConnectionToES.EsClient().Search <DocumentAttributes>(s => s
                                                                                 .Index("places")
                                                                                 .Type("hotel")
                                                                                 .Query(q => q.Term(t => t.Field("_id").Value(searchID)))); //Search based in _id

            //var response = ConnectionToES.EsClient().Search<DocumentAttributes>(s => s
            //  .Index("places")
            //  .Type("hotel")
            //  .Query(q => q
            //    .Match(t => t.
            //        Query("animated_debut")
            //        .Field((searchID))
            //            )
            //        )
            //        );

            //Assigining value to their controller
            foreach (var hit in response.Hits)
            {
                id   = hit.Id.ToString();// Source.id.ToString();
                name = hit.Source.name.ToString();
                originalVoiceActor = hit.Source.original_voice_actor.ToString();
                animatedDebut      = Convert.ToInt32(hit.Source.animated_debut);
            }

            return(Tuple.Create(id, name, originalVoiceActor, animatedDebut));
        }
예제 #2
0
        public static bool insertDocument(string searchID, string tbxname, string tbxOriginalVoiceActor, string tbxAnimatedDebut)
        {
            bool status;

            var myJson = new
            {
                name = tbxname,
                original_voice_actor = tbxOriginalVoiceActor,
                animated_debut       = tbxAnimatedDebut
            };

            var response = ConnectionToES.EsClient().Index(myJson, i => i
                                                           .Index("disney")
                                                           .Type("character")
                                                           .Id(searchID));

            //  .Refresh());

            if (response.IsValid)
            {
                status = true;
            }
            else
            {
                status = false;
            }

            return(status);
        }
예제 #3
0
        public static bool insertDocument(string searchID, string tbxfirstname, string tbxLastname, string tbxcity)
        {
            bool status;

            var myJson = new
            {
                firstname = tbxfirstname,
                lastname  = tbxLastname,
                city      = tbxcity,
            };

            var response = ConnectionToES.EsClient().Index(myJson, i => i
                                                           .Index("accounts3")
                                                           .Type("account3")
                                                           .Id(searchID)
                                                           .Refresh());

            if (response.IsValid)
            {
                status = true;
            }
            else
            {
                status = false;
            }
            getAllDocument();

            return(status);
        }
예제 #4
0
        ///Updating a Document can be done in trhee way
        ///1. Update by Partial Document
        ///2. Update by Index Query
        ///3. Update by Script
        ///Here we demonstrated Update by Partial Document and  Update by Index Query. User can choose any of these from below.
        ///Just comment one part and uncomment another.

        public static bool updateDocument(string searchID, string tbxfirstname, string tbxLastname, string tbxcity)
        {
            bool status;

            //Update by Partial Document
            var response = ConnectionToES.EsClient().Update <DocumentAttributes, UpdateDocumentAttributes>(searchID, d => d
                                                                                                           .Index("accounts3")
                                                                                                           .Type("account3")
                                                                                                           .Doc(new UpdateDocumentAttributes
            {
                firstname = tbxfirstname,
                lastname  = tbxLastname,
                city      = tbxcity,
            }));


            if (response.IsValid)
            {
                status = true;
            }
            else
            {
                status = false;
            }
            getAllDocument();

            return(status);
        }
예제 #5
0
        ///Updating a Document can be done in trhee way
        ///1. Update by Partial Document
        ///2. Update by Index Query
        ///3. Update by Script
        ///Here we demonstrated Update by Partial Document and  Update by Index Query. User can choose any of these from below.
        ///Just comment one part and uncomment another.

        public static bool updateDocument(string searchID, string tbxname, string tbxOriginalVoiceActor, string tbxAnimatedDebut)
        {
            bool status;

            //Update by Partial Document
            //var response = ConnectionToES.EsClient().Update<DocumentAttributes, UpdateDocumentAttributes>(searchID, d => d
            //    .Index("disney")
            //    .Type("character")
            //    .Doc(new UpdateDocumentAttributes
            //    {
            //        name = tbxname,
            //        original_voice_actor = tbxOriginalVoiceActor,
            //        animated_debut = tbxAnimatedDebut
            //    }));


            //End of Update by Partial Document

            //Update by Index Query
            var myJson = new
            {
                name = tbxname,
                original_voice_actor = tbxOriginalVoiceActor,
                animated_debut       = tbxAnimatedDebut
            };

            var response = ConnectionToES.EsClient().Index(myJson, i => i
                                                           .Index("disney")
                                                           .Type("character")
                                                           .Id(searchID)
                                                           .Refresh());

            //End of Update by Index Query

            if (response.IsValid)
            {
                status = true;
            }
            else
            {
                status = false;
            }

            return(status);
        }
예제 #6
0
        public static Tuple<string, string, string, string> getDocument(string searchName)
        {
            string id = "";
            string name = "";
            string originalVoiceActor = "";
            string animatedDebut = "";

            var response = ConnectionToES.EsClient().Search<DocumentAttributes>(s => s
                .Index("disney")
                .Type("character")
                .Query(q => q.QueryString(

                            qs => qs.Query(searchName)
                            .AllowLeadingWildcard(true)
                            )


                )
                

                ); //Search based in _id                

            //Assigining value to their controller
            List<tmp> rs = new List<tmp>();

            foreach (var hit in response.Hits)
            {
                id = hit.Id.ToString();// Source.id.ToString();
                name = hit.Source.name.ToString();
                originalVoiceActor = hit.Source.original_voice_actor.ToString();
                animatedDebut = hit.Source.animated_debut.ToString();
                var tmp = new List<Tuple<int,string>> 
                {
                 Tuple.Create(id, name, originalVoiceActor, animatedDebut)
                };


                
                    
                    )
            }

            return 
        }
예제 #7
0
        ///Updating a Document can be done in trhee way
        ///1. Update by Partial Document
        ///2. Update by Index Query
        ///3. Update by Script
        ///Here we demonstrated Update by Partial Document and  Update by Index Query. User can choose any of these from below.
        ///Just comment one part and uncomment another.

        public static bool updateDocument(string searchID, string tbxname, string tbxOriginalVoiceActor, string tbxAnimatedDebut)
        {
            bool status;

            //Update by Partial Document
            var response = ConnectionToES.EsClient().Update <DocumentAttributes, UpdateDocumentAttributes>(searchID, d => d
                                                                                                           .Index("places")
                                                                                                           .Type("hotel")
                                                                                                           .Doc(new UpdateDocumentAttributes
            {
                name = tbxname,
                original_voice_actor = tbxOriginalVoiceActor,
                animated_debut       = tbxAnimatedDebut
            }));

            //End of Update by Partial Document

            //Update by Index Query

            /*var myJson = new
             * {
             *  name = tbxname,
             *  original_voice_actor = tbxOriginalVoiceActor,
             *  animated_debut = tbxAnimatedDebut
             * };
             *
             * var response = ConnectionToES.EsClient().Index(myJson, i => i
             *  .Index("places")
             *  .Type("hotel")
             *  .Id(searchID)
             *  .Refresh());*/
            //End of Update by Index Query

            if (response.IsValid)
            {
                status = true;
            }
            else
            {
                status = false;
            }

            return(status);
        }
예제 #8
0
        public static bool deleteDocument(string searchID)
        {
            bool status;

            var response = ConnectionToES.EsClient().Delete <DocumentAttributes>(searchID, d => d
                                                                                 .Index("disney")
                                                                                 .Type("character"));

            if (response.IsValid)
            {
                status = true;
            }
            else
            {
                status = false;
            }

            return(status);
        }
예제 #9
0
        public static bool deleteDocument(string searchID)
        {
            bool status;

            var response = ConnectionToES.EsClient().Delete <DocumentAttributes>(searchID, d => d
                                                                                 .Index("accounts3")
                                                                                 .Type("account3"));

            if (response.IsValid)
            {
                status = true;
            }
            else
            {
                status = false;
            }
            getAllDocument();
            return(status);
        }
예제 #10
0
        public static DataTable getAllDocument()
        {
            DataTable dataTable = new DataTable("disney");
            dataTable.Columns.Add("ID", typeof(string));
            dataTable.Columns.Add("Name", typeof(string));
            dataTable.Columns.Add("Original Voice Actor", typeof(string));
            dataTable.Columns.Add("Animated Debut", typeof(string));

            var response = ConnectionToES.EsClient().Search<DocumentAttributes>(s => s
                .Index("disney")
                .Type("character")
                .From(0)
                .Size(1000)
                .Query(q => q.MatchAll()));

            foreach (var hit in response.Hits)
            {
                dataTable.Rows.Add(hit.Id.ToString(), hit.Source.name.ToString(), hit.Source.original_voice_actor.ToString(), hit.Source.animated_debut.ToString());
            }

            return dataTable;
        }
예제 #11
0
        public static Tuple <string, string, string, string> getDocument(string searchID)
        {
            string id   = "";
            string name = "";
            string originalVoiceActor = "";
            string animatedDebut      = "";

            var response = ConnectionToES.EsClient().Search <DocumentAttributes>(s => s
                                                                                 .Index("disney")
                                                                                 .Type("character")
                                                                                 .Query(q => q.Term(t => t.Field("_id").Value(searchID)))); //Search based in _id

            //Assigining value to their controller
            foreach (var hit in response.Hits)
            {
                id   = hit.Id.ToString();// Source.id.ToString();
                name = hit.Source.name.ToString();
                originalVoiceActor = hit.Source.original_voice_actor.ToString();
                animatedDebut      = hit.Source.animated_debut.ToString();
            }

            return(Tuple.Create(id, name, originalVoiceActor, animatedDebut));
        }
예제 #12
0
        public static Tuple <string, string, string, string> getDocument(string searchID)
        {
            string id        = "";
            string firstname = "";
            string lastname  = "";
            string city      = "";

            var response = ConnectionToES.EsClient().Search <DocumentAttributes>(s => s
                                                                                 .Index("accounts3")
                                                                                 .Type("account3")
                                                                                 .Query(q => q.Term(t => t.Field("_id").Value(searchID)))); //Search based in _id

            //Assigining value to their controller
            foreach (var hit in response.Hits)
            {
                id        = hit.Id.ToString();// Source.id.ToString();
                firstname = hit.Source.firstname.ToString();
                lastname  = hit.Source.lastname.ToString();
                city      = hit.Source.city.ToString();
            }

            return(Tuple.Create(id, firstname, lastname, city));
        }
예제 #13
0
        public static DataTable getAllDocument()
        {
            DataTable dataTable = new DataTable("character");

            dataTable.Columns.Add("account_number", typeof(string));
            dataTable.Columns.Add("firstname", typeof(string));
            dataTable.Columns.Add("lastname", typeof(string));
            dataTable.Columns.Add("age", typeof(string));

            var response = ConnectionToES.EsClient().Search <DocumentAttributes>(s => s
                                                                                 .Index("accounts3")
                                                                                 .Type("account3")
                                                                                 .From(0)
                                                                                 .Size(1000)
                                                                                 .Query(q => q.MatchAll()));

            foreach (var hit in response.Hits)
            {
                dataTable.Rows.Add(hit.Id.ToString(), hit.Source.firstname.ToString(), hit.Source.lastname.ToString(), hit.Source.city.ToString());
            }

            return(dataTable);
        }
예제 #14
0
        /*
         * public static bool insertDocument(string searchID, string tbxname, string tbxOriginalVoiceActor, string tbxAnimatedDebut)
         * {
         *  bool status;
         *
         *  var myJson = new
         *  {
         *      name = tbxname,
         *      original_voice_actor = tbxOriginalVoiceActor,
         *      animated_debut = tbxAnimatedDebut
         *  };
         *
         *  var response = ConnectionToES.EsClient().Index(myJson, i => i
         *      .Index("tdindex")
         *
         *      .Type("phonetic")
         *      .Id(searchID)
         *      .Refresh());
         *
         *  if (response.IsValid)
         *  {
         *      status = true;
         *  }
         *  else
         *  {
         *      status = false;
         *  }
         *
         *  return status;
         * }
         */
        /*
         * public static bool insertDocument(string searchID, object obj)
         * {
         *  bool status;
         *
         *  var response = ConnectionToES.EsClient().Index(obj, i => i
         *      .Index("tdindex")
         *      .Type("phonetic")
         *      .Id(searchID)
         *      .Refresh());
         *
         *  if (response.IsValid)
         *  {
         *      status = true;
         *  }
         *  else
         *  {
         *      status = false;
         *  }
         *
         *  return status;
         * }
         *
         *
         */
        public static bool insertDocument(object obj, int searchID)
        {
            var client = ConnectionToES.EsClient();

            bool status;

            /*
             * var createIndexResponse = client.CreateIndex("testing", c => c
             * .Mappings(ms => ms
             * .Map<DocumentModel>(m => m
             * .Properties(ps => ps
             *
             * ).AutoMap()
             * )
             *
             * )
             * );*/


            var response = client.Index(obj, i => i
                                        .Index("antelope")
                                        .Type("documentModel")
                                        .Id(searchID)
                                        .Refresh());

            if (response.IsValid)
            {
                status = true;
            }
            else
            {
                status = false;
            }

            return(status);
        }