Example #1
0
        private static void ListIndexAliases(ElasticConnection connection, JsonNetSerializer serializer)
        {
            /*
             * curl -XGET http://localhost:9200/twitter/_aliases
             */

            string indexAliasCommand = Commands.IndexAliases("twitter")
                                       .Pretty();

            var result = connection.Get(indexAliasCommand);

            // Parse index result.
            var indexAliasResult = serializer.ToIndexAliasesResult(result);

            PrintIndexAliasListResult(indexAliasResult, indexAliasCommand, result);
        }
Example #2
0
 public T QuerySingle(string id)
 {
     try
     {
         string          getCommand = new GetCommand(_indexInfo.IndexName, _indexInfo.IndexType, id);
         OperationResult result     = Client.Get(getCommand);
         var             getResult  = serializer.ToGetResult <T>(result.Result);
         if (getResult.found)
         {
             return(getResult.Document);
         }
         return(null);
     }
     catch (OperationException ex) {
         return(null);
     }
 }
Example #3
0
        private static Tweet GetTweet(string id, JsonNetSerializer serializer, ElasticConnection connection)
        {
            /*
             * $ curl -XGET 'http://localhost:9200/twitter/tweet/1?pretty=true'
             */

            String getCommand = Commands.Get(index: "twitter", type: "tweet", id: id).Pretty(); // this will generate: twitter/tweet/1?pretty=true

            var result = connection.Get(getCommand);

            // Deserialize Get command result to GetResult object.
            var getResult = serializer.ToGetResult <Tweet>(result);

            var getTweet = getResult.Document;

            PrintGetCommand(getTweet, result, getCommand);

            return(getTweet);
        }