Migrating simple parent child to 6.x using a join type field

After a few of days of investigation and reading different links and documentation I'm feeling a bit defeated on how to migrate a simple parent child relationship defined in 2.x to 6.x. As I understand going foward single types and join should replace the functionality of parent/child relationships I've tried to make the jump without much success so I wonder if someone could help me out here. I think my problem lies on the mapping and the way of using the java High Level Client to populate the children.

BEFORE (2.x)

Our mapping would be something like following:

    {
      "settings": {
      },
      "index": {
        "max_result_window" : 100000
      },
      "mappings": {
        "family": {
          "_all": {
            "enabled": false
          },
          "properties": {
            "conversionYears": {
              "type": "integer"
            },
            "patFamId": {
              "type": "integer",
              "index": "no"
            },
            "title": {
              "type": "string",
              "fields": {
                "raw": {
                  "type": "string",
                  "index": "not_analyzed"
                }
              }
            },
           ....
        },
        "process": {
          "_all": {
            "enabled": false
          },
          "_parent": {
            "type": "family",
            "fielddata": {
              "loading": "eager_global_ordinals"
            }
          },
          "properties": {
            "processId": {
              "type": "string",
              "index": "not_analyzed"
            },
           ....
      }
    }

CURRENTLY (6.2)

We are trying to move to a flatter mapping:

    {
      "settings": {... },
      "index": {
        "max_result_window" : 100000
      },
      "mappings": {
        "_doc" : {
          "properties": {
            "parent_child_relation": {
              "type": "join",
              "relations": {
                "patFamId": "processId"
              },
              "eager_global_ordinals" : true
            },
            "processId": {
              "type": "keyword",
              "index": "true"
            },
            ...
           "processName": {
              "type": "keyword",
              "fields": {
                "raw": {
                  "type": "keyword",
                  "index": "true"
                }
              }
            },
            "patFamId": {
              "type": "integer",
              "index": "false"
            },
            "title": {
              "type": "keyword",
              "fields": {
                "raw": {
                  "type": "keyword",
                  "index": "true"
                }
              }
            },
           ...
    }
    }

My questions would be:

  1. Is the mapping migration correct?
  2. How that mapping would change "put" and "search" operations when inserting children and doing the same searches as before?

For the latter is probably where I get more lost as although moved to the java High Level client there seems to be possible doing things (compiling time) like the following:

(inserting children into index)
....

    FamilyWithMeta.Process processES = new PatentFamilyWithMeta.Process(processId, name,
                 cluster.id(), cluster.description());
    sharedQueue.put(new IndexRequest(INDEX,"_doc")
                     .source(MAPPER.convertValue(processES, Map.class)).parent(Integer.toString(member)));

....

(querying)
...

    SearchRequest searchRequest = new SearchRequest(INDEX)
            .source((new SearchSourceBuilder()
                    .query(JoinQueryBuilders.hasChildQuery("_doc",
                            filterByProcessAndCluster(reportMetadata.target().process(), processes, allClusters),
                            ScoreMode.None))
                    .explain(false)))
            .types("_doc")
            .searchType(SearchType.QUERY_THEN_FETCH);

...

When running I get the following error:
index [cipher], type [doc], id [null], message [ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=can't specify parent if no parent field has been configured]]]

I think it's a combination of things I'm not getting right but any help or real example that includes the three elements: <<mapping on a single index, writing children and querying them>> would help.

So far I find spare examples but not real ones about "before" and "after" to understand the inner details and also how the java client would be used when the mapping changes to simple type+join fields.

Many thanks,
Gemma

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.