SOLR Order Document by the closest child document location





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







0















Is it possible to calculate a distance for every element of a child and sort the parent document based on the minimum value of this?



My concrete use case is that I have products that have a list of shop-documents as children. I want to find the closest products to a specified location based on the list of shops that are child documents of that product.



[{
"nodeType":product,
"title": lenovo notebook
"shops": [{"id":1, latitude:48.3, longitude:16.8, ...}, ...]
},
{
"nodeType":product,
"title": apple notebook
"shops": [{"id":4, latitude:47.3, longitude:15.8, ...}, ...]
}, ...
...]


The result I want to have is to find products fitting a specific query (q=lenovo) and sort them by the distance to a passed location from the user. Hence, I need to calculate the distance to every shop in the shops list and find the minimum value and sort it by this minimum value.



geodist, dist, etc. do not seem to fit here. Does anybody have a tip or workaround to solve this problem?










share|improve this question































    0















    Is it possible to calculate a distance for every element of a child and sort the parent document based on the minimum value of this?



    My concrete use case is that I have products that have a list of shop-documents as children. I want to find the closest products to a specified location based on the list of shops that are child documents of that product.



    [{
    "nodeType":product,
    "title": lenovo notebook
    "shops": [{"id":1, latitude:48.3, longitude:16.8, ...}, ...]
    },
    {
    "nodeType":product,
    "title": apple notebook
    "shops": [{"id":4, latitude:47.3, longitude:15.8, ...}, ...]
    }, ...
    ...]


    The result I want to have is to find products fitting a specific query (q=lenovo) and sort them by the distance to a passed location from the user. Hence, I need to calculate the distance to every shop in the shops list and find the minimum value and sort it by this minimum value.



    geodist, dist, etc. do not seem to fit here. Does anybody have a tip or workaround to solve this problem?










    share|improve this question



























      0












      0








      0








      Is it possible to calculate a distance for every element of a child and sort the parent document based on the minimum value of this?



      My concrete use case is that I have products that have a list of shop-documents as children. I want to find the closest products to a specified location based on the list of shops that are child documents of that product.



      [{
      "nodeType":product,
      "title": lenovo notebook
      "shops": [{"id":1, latitude:48.3, longitude:16.8, ...}, ...]
      },
      {
      "nodeType":product,
      "title": apple notebook
      "shops": [{"id":4, latitude:47.3, longitude:15.8, ...}, ...]
      }, ...
      ...]


      The result I want to have is to find products fitting a specific query (q=lenovo) and sort them by the distance to a passed location from the user. Hence, I need to calculate the distance to every shop in the shops list and find the minimum value and sort it by this minimum value.



      geodist, dist, etc. do not seem to fit here. Does anybody have a tip or workaround to solve this problem?










      share|improve this question
















      Is it possible to calculate a distance for every element of a child and sort the parent document based on the minimum value of this?



      My concrete use case is that I have products that have a list of shop-documents as children. I want to find the closest products to a specified location based on the list of shops that are child documents of that product.



      [{
      "nodeType":product,
      "title": lenovo notebook
      "shops": [{"id":1, latitude:48.3, longitude:16.8, ...}, ...]
      },
      {
      "nodeType":product,
      "title": apple notebook
      "shops": [{"id":4, latitude:47.3, longitude:15.8, ...}, ...]
      }, ...
      ...]


      The result I want to have is to find products fitting a specific query (q=lenovo) and sort them by the distance to a passed location from the user. Hence, I need to calculate the distance to every shop in the shops list and find the minimum value and sort it by this minimum value.



      geodist, dist, etc. do not seem to fit here. Does anybody have a tip or workaround to solve this problem?







      java solr geolocation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 28 at 21:21









      Pikachu the Purple Wizard

      2,04961529




      2,04961529










      asked Nov 23 '18 at 15:20









      kbaxkbax

      136




      136
























          0






          active

          oldest

          votes












          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%2f53449199%2fsolr-order-document-by-the-closest-child-document-location%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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%2f53449199%2fsolr-order-document-by-the-closest-child-document-location%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

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          Origin of the phrase “under your belt”?