0

I have defined two indexes in elasticsearch that are populated with two different queries coming from a postgres database. I have many hundred of documents with thousand of keywords, and I have used logstash to populate the two indexes.

The first index is called publication and is defined as follow:

"mappings" : {
  "doc" : {
    "properties" : {
      "external_id" : {"type": "text" },
      "title" : {"type": "text", "analyzer":"english" },
      "description" : { "type" : "text", "analyzer":"english" }
    }
  }
}

The second index is called keyword and is defined as follow:

"mappings" : {
   "doc" : {
      "properties" : {
         "publication_id" : {"type": "keyword" },
         "keyword" :  {"type": "keyword" }
      }
   }
}

The relationship between the two indexes is based on the external_id <-> publication_id.

I am trying to define other indexes in a way that I can locate all the publications that have a specific keyword or all the keywords that are defined for a specific publication

Nicola Lepetit
  • 756
  • 8
  • 25
  • Do you want to find all `publication` documents only having the `publication_id` of a `keyword` document? – ThomasC Jul 12 '18 at 13:06
  • Not exactly. I would like to search for a keyword and have the list of all publications details of those that contains the searched keyword. – Nicola Lepetit Jul 12 '18 at 13:32
  • Thanks :) In this case, which version of ES are you using? – ThomasC Jul 12 '18 at 13:51
  • The version is 6.3.1 – Nicola Lepetit Jul 12 '18 at 13:57
  • 1
    In this case, you won't be able to use parent-child relationship if you keep these documents in different indices. It's only possible if they are in the same index. You could use a [terms query with terms lookup](https://www.elastic.co/guide/en/elasticsearch/reference/6.3/query-dsl-terms-query.html#query-dsl-terms-lookup), but to achieve this you would have to know the `keyword` document id before. – ThomasC Jul 12 '18 at 14:39

0 Answers0