Beispiel #1
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 = ElasticSearch.EsClient().Index(myJson, i => i
                                                          .Index("disney")
                                                          .Type("character")
                                                          .Id(searchID)
                                                          .Refresh());

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

            return(status);
        }
Beispiel #2
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 = ElasticSearch.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);
        }
Beispiel #3
0
        public static bool deleteDocument(string searchID)
        {
            bool status;

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

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

            return(status);
        }