0

I have two indexes my first index test file is as follow:

{
"took": 31,
"timed_out": false,
"_shards": {
  "total": 1,
  "successful": 1,
  "failed": 0
},
"hits": {
  "total": 259636,
  "max_score": 0.012848643,
  "hits": [
     {
        "_index": "test",
        "_type": "testtype",
        "_id": "AV0TAUuCWj5Ta51I8M6S",
        "_score": 0.012848643,
        "_source": {
           "resource": "a6fa3184-3845-475e-b87b-866a92edae0c",
           "cookie_user": "9e3f8294-b0b8-89b2-55c6-94ec49bb2322",
           "user": "ffffffff-ffff-ffff-ffff-ffffffffffff"

        }
     }
    }

My second index resources file is as follow

    {
   "took": 2,
   "timed_out": false,
    "_shards": {
  "total": 5,
  "successful": 5,
  "failed": 0
    },
  "hits": {
  "total": 84796,
  "max_score": 1,
         "hits": [
           {
          "_index": "resources",
        "_type": "resourcestype",
        "_id": "AV0SrP_Sa_bOoMdWCF42",
        "_score": 1,
        "_source": {
           "haseditor": [
              "equipo didactalia"
           ],
           "hasnumeroComentarios": [
              "0"
            ],

           "ID": "a6fa3184-3845-475e-b87b-866a92edae0c",

           "hasTituloDesc": [
              " is there a relationship between tempo and genre  "
           ],
           "haspublicador": [
              "consultor2 gnoss"
           ]
        }
     } 
    }

The resource field of test index document is same as ID field of resources index document.

I want to write a query to find all fields of both index documents having resource value "a6fa3184-3845-475e-b87b-866a92edae0c" of test document equal to ID value of resources document. Your help is highly appreciated.

  • This answer should help: https://stackoverflow.com/questions/33335303/how-to-join-two-indexes-in-elasticsearch/33338598#33338598 – Val Jul 10 '17 at 12:51
  • Thanks @Val for your comment but I need Java querybuilder query – user2778724 Jul 10 '17 at 13:20
  • What the answer suggests is that you should take some time to think about how to properly denormalize your data beforehand in order to get rid of the necessity of doing a JOIN. – Val Jul 10 '17 at 13:26

0 Answers0