Is it possible to use ElasticSearch.Net or Nest for dynamic response





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















Is there a client.Read(...) without generics? I have found none, neither in Nest nor ElasticSearch.Net.





Version 1.5 has an IDocument that might solve my problem but I cannot use that version with Elasticsearch5.5.



All examples, version 5 and 6, of ElasticSearch.Net and Nest require me to know the format of the response as generic at compile time. E.g. Read<Customer>(...)



My problem is that the we do not know the format of the database and we don't know the format of the output; but it should all be configurable.










share|improve this question





























    1















    Is there a client.Read(...) without generics? I have found none, neither in Nest nor ElasticSearch.Net.





    Version 1.5 has an IDocument that might solve my problem but I cannot use that version with Elasticsearch5.5.



    All examples, version 5 and 6, of ElasticSearch.Net and Nest require me to know the format of the response as generic at compile time. E.g. Read<Customer>(...)



    My problem is that the we do not know the format of the database and we don't know the format of the output; but it should all be configurable.










    share|improve this question

























      1












      1








      1


      1






      Is there a client.Read(...) without generics? I have found none, neither in Nest nor ElasticSearch.Net.





      Version 1.5 has an IDocument that might solve my problem but I cannot use that version with Elasticsearch5.5.



      All examples, version 5 and 6, of ElasticSearch.Net and Nest require me to know the format of the response as generic at compile time. E.g. Read<Customer>(...)



      My problem is that the we do not know the format of the database and we don't know the format of the output; but it should all be configurable.










      share|improve this question














      Is there a client.Read(...) without generics? I have found none, neither in Nest nor ElasticSearch.Net.





      Version 1.5 has an IDocument that might solve my problem but I cannot use that version with Elasticsearch5.5.



      All examples, version 5 and 6, of ElasticSearch.Net and Nest require me to know the format of the response as generic at compile time. E.g. Read<Customer>(...)



      My problem is that the we do not know the format of the database and we don't know the format of the output; but it should all be configurable.







      elasticsearch nest elasticsearch-5 elasticsearch-net






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 26 '18 at 13:54









      LosManosLosManos

      3,51452767




      3,51452767
























          2 Answers
          2






          active

          oldest

          votes


















          1














          You can use dynamic as the generic type if the response is truly dynamic.



          In 5.x, this will be Json.NET's JObject type under the covers (so you could use JObject instead if you prefer).



          In 6.x, dynamic will also work but the actual type will be an internal JObject type. If you would prefer to work with Json.NET's JObject type, you can hook up Json.NET as the serializer using the NEST.JsonNetSerializer nuget package, to use as the serializer for your documents and then use its JObject type as per 5.x.






          share|improve this answer































            0














            (Feels strange to answer my own question but I want to show the resulting code for future reference.)



            var settings = new ConnectionSettings(new Uri(@"http://localnhost:9200"))
            .DefaultIndex("myindex");
            var client = new ElasticClient(settings);

            var res = client.Search<dynamic>(s => s
            .AllTypes());

            var rows = res.Documents;
            Assert.IsTrue(rows.Count >= 1);

            dynamic row = res.Documents.First();
            Assert.AreEqual("50.7031526", row.POSITION.lat.ToString()); // It is case sensitive.
            Assert.AreEqual(50.7031526, (double)row.POSITION.lat); // Convert to type explicitly.





            share|improve this answer


























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53482642%2fis-it-possible-to-use-elasticsearch-net-or-nest-for-dynamic-response%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              You can use dynamic as the generic type if the response is truly dynamic.



              In 5.x, this will be Json.NET's JObject type under the covers (so you could use JObject instead if you prefer).



              In 6.x, dynamic will also work but the actual type will be an internal JObject type. If you would prefer to work with Json.NET's JObject type, you can hook up Json.NET as the serializer using the NEST.JsonNetSerializer nuget package, to use as the serializer for your documents and then use its JObject type as per 5.x.






              share|improve this answer




























                1














                You can use dynamic as the generic type if the response is truly dynamic.



                In 5.x, this will be Json.NET's JObject type under the covers (so you could use JObject instead if you prefer).



                In 6.x, dynamic will also work but the actual type will be an internal JObject type. If you would prefer to work with Json.NET's JObject type, you can hook up Json.NET as the serializer using the NEST.JsonNetSerializer nuget package, to use as the serializer for your documents and then use its JObject type as per 5.x.






                share|improve this answer


























                  1












                  1








                  1







                  You can use dynamic as the generic type if the response is truly dynamic.



                  In 5.x, this will be Json.NET's JObject type under the covers (so you could use JObject instead if you prefer).



                  In 6.x, dynamic will also work but the actual type will be an internal JObject type. If you would prefer to work with Json.NET's JObject type, you can hook up Json.NET as the serializer using the NEST.JsonNetSerializer nuget package, to use as the serializer for your documents and then use its JObject type as per 5.x.






                  share|improve this answer













                  You can use dynamic as the generic type if the response is truly dynamic.



                  In 5.x, this will be Json.NET's JObject type under the covers (so you could use JObject instead if you prefer).



                  In 6.x, dynamic will also work but the actual type will be an internal JObject type. If you would prefer to work with Json.NET's JObject type, you can hook up Json.NET as the serializer using the NEST.JsonNetSerializer nuget package, to use as the serializer for your documents and then use its JObject type as per 5.x.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 26 '18 at 23:12









                  Russ CamRuss Cam

                  105k24170229




                  105k24170229

























                      0














                      (Feels strange to answer my own question but I want to show the resulting code for future reference.)



                      var settings = new ConnectionSettings(new Uri(@"http://localnhost:9200"))
                      .DefaultIndex("myindex");
                      var client = new ElasticClient(settings);

                      var res = client.Search<dynamic>(s => s
                      .AllTypes());

                      var rows = res.Documents;
                      Assert.IsTrue(rows.Count >= 1);

                      dynamic row = res.Documents.First();
                      Assert.AreEqual("50.7031526", row.POSITION.lat.ToString()); // It is case sensitive.
                      Assert.AreEqual(50.7031526, (double)row.POSITION.lat); // Convert to type explicitly.





                      share|improve this answer






























                        0














                        (Feels strange to answer my own question but I want to show the resulting code for future reference.)



                        var settings = new ConnectionSettings(new Uri(@"http://localnhost:9200"))
                        .DefaultIndex("myindex");
                        var client = new ElasticClient(settings);

                        var res = client.Search<dynamic>(s => s
                        .AllTypes());

                        var rows = res.Documents;
                        Assert.IsTrue(rows.Count >= 1);

                        dynamic row = res.Documents.First();
                        Assert.AreEqual("50.7031526", row.POSITION.lat.ToString()); // It is case sensitive.
                        Assert.AreEqual(50.7031526, (double)row.POSITION.lat); // Convert to type explicitly.





                        share|improve this answer




























                          0












                          0








                          0







                          (Feels strange to answer my own question but I want to show the resulting code for future reference.)



                          var settings = new ConnectionSettings(new Uri(@"http://localnhost:9200"))
                          .DefaultIndex("myindex");
                          var client = new ElasticClient(settings);

                          var res = client.Search<dynamic>(s => s
                          .AllTypes());

                          var rows = res.Documents;
                          Assert.IsTrue(rows.Count >= 1);

                          dynamic row = res.Documents.First();
                          Assert.AreEqual("50.7031526", row.POSITION.lat.ToString()); // It is case sensitive.
                          Assert.AreEqual(50.7031526, (double)row.POSITION.lat); // Convert to type explicitly.





                          share|improve this answer















                          (Feels strange to answer my own question but I want to show the resulting code for future reference.)



                          var settings = new ConnectionSettings(new Uri(@"http://localnhost:9200"))
                          .DefaultIndex("myindex");
                          var client = new ElasticClient(settings);

                          var res = client.Search<dynamic>(s => s
                          .AllTypes());

                          var rows = res.Documents;
                          Assert.IsTrue(rows.Count >= 1);

                          dynamic row = res.Documents.First();
                          Assert.AreEqual("50.7031526", row.POSITION.lat.ToString()); // It is case sensitive.
                          Assert.AreEqual(50.7031526, (double)row.POSITION.lat); // Convert to type explicitly.






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Dec 4 '18 at 7:50

























                          answered Nov 27 '18 at 10:13









                          LosManosLosManos

                          3,51452767




                          3,51452767






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53482642%2fis-it-possible-to-use-elasticsearch-net-or-nest-for-dynamic-response%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Wiesbaden

                              Marschland

                              Dieringhausen