# Hibernate Search 6 - Advanced mapping

**URL:** <https://discourse.hibernate.org/t/hibernate-search-6-advanced-mapping/2996>\
**Category:** Hibernate Search\
**Created:** [July 22, 2019, 8:56am UTC](https://discourse.hibernate.org/t/hibernate-search-6-advanced-mapping/2996 "2019-07-22T08:56:45Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Alexis\_Cucumel](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/alexis_cucumel/32/687_2.png) [@Alexis\_Cucumel](https://discourse.hibernate.org/u/Alexis_Cucumel)\
**Post date:** [July 23, 2019, 1:27pm UTC](https://discourse.hibernate.org/t/hibernate-search-6-advanced-mapping/2996/5 "2019-07-23T13:27:03Z")

</div>

Ok, with the new code  
@AssociationInverseSide(inversePath = @ObjectPath(@PropertyValue(propertyName = “conjoint”)))

I’m able to index my document as expected with fullIndexer

Here is the mapping seen from **kibana**

```auto
{
  "mapping": {
    "dynamic": "strict",
    "properties": {
      "__HSEARCH_id": {
        "type": "keyword",
        "store": true
      },
      "__HSEARCH_tenantId": {
        "type": "keyword",
        "store": true
      },
      "conjoint": {
        "dynamic": "strict",
        "properties": {
          "dateNe": {
            "type": "date",
            "doc_values": false,
            "format": "uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSSZZZZZ"
          },
          "nom": {
            "type": "keyword",
            "doc_values": false
          },
          "prenom": {
            "type": "keyword",
            "doc_values": false
          },
          "uuid": {
            "type": "keyword",
            "doc_values": false
          }
        }
      },
      "dateNe": {
        "type": "date",
        "doc_values": false,
        "format": "uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSSZZZZZ"
      },
      "nom": {
        "type": "keyword",
        "doc_values": false
      },
      "prenom": {
        "type": "keyword",
        "doc_values": false
      },
      "uuid": {
        "type": "keyword",
        "doc_values": false
      }
    }
  }
}

```

Here an example of two indexed ClientPhysique

1

```auto
"_source": {
    "uuid": "8cebe01d-b9cf-45c8-956c-00b7d6252c98",
    "dateNe": "1984-11-25T23:00:00.000000000Z",
    "nom": "test444",
    "prenom": "Vanessa, Fatima",
    "conjoint": {
      "uuid": "a4dc702e-4253-4134-94ad-fb14206eb0ea",
      "dateNe": "1982-10-21T23:00:00.000000000Z",
      "nom": "LOSSIGNOL",
      "prenom": "Vincent, Nicolas"
    },
    "__HSEARCH_id": "2828",
    "__HSEARCH_tenantId": ""
  },

```

2

```auto
"_source": {
    "uuid": "a4dc702e-4253-4134-94ad-fb14206eb0ea",
    "dateNe": "1982-10-21T23:00:00.000000000Z",
    "nom": "LOSSIGNOL",
    "prenom": "Vincent, Nicolas",
    "conjoint": {
      "uuid": "8cebe01d-b9cf-45c8-956c-00b7d6252c98",
      "dateNe": "1984-11-25T23:00:00.000000000Z",
      "nom": "test444",
      "prenom": "Vanessa, Fatima"
    },
    "__HSEARCH_id": "2827",
    "__HSEARCH_tenantId": ""
  },

```

Now my next issue is when i try to update one side of the association it’s not updating correctly the embedded document, actually, the object i just updated loose his embeded document.

```auto
ClientPhysique c = rootRepository.get(ClientPhysique.class, 2828l);
c.setNom("test2000");
rootRepository.saveOrUpdate(c);

```

here the indexed documents after the update of one side

Here the entity i just update (id **2828l** ) which loose his **conjoint**

```auto
"_source": {
    "uuid": "8cebe01d-b9cf-45c8-956c-00b7d6252c98",
    "dateNe": "1984-11-25T23:00:00.000000000Z",
    "nom": "test2000",
    "prenom": "Vanessa, Fatima",
    "conjoint": {
      "uuid": null,
      "dateNe": null,
      "nom": null,
      "prenom": null
    },
    "__HSEARCH_id": "2828",
    "__HSEARCH_tenantId": ""
  }

```

Here the other entity, **everything fine**

```auto
"_source": {
    "uuid": "a4dc702e-4253-4134-94ad-fb14206eb0ea",
    "dateNe": "1982-10-21T23:00:00.000000000Z",
    "nom": "LOSSIGNOL",
    "prenom": "Vincent, Nicolas",
    "conjoint": {
      "uuid": "8cebe01d-b9cf-45c8-956c-00b7d6252c98",
      "dateNe": "1984-11-25T23:00:00.000000000Z",
      "nom": "test2000",
      "prenom": "Vanessa, Fatima"
    },
    "__HSEARCH_id": "2827",
    "__HSEARCH_tenantId": ""
  }

```

If i do this , documents are both ok but i’am not sure it’s relevant

```auto
ClientPhysique c = rootRepository.get(ClientPhysique.class, 2827l);
c.setNom("left side 1");
rootRepository.saveOrUpdate(c);
ClientPhysique c2 = rootRepository.get(ClientPhysique.class, 2828l);
c2.setNom("right side 1");
rootRepository.saveOrUpdate(c2);

```

The last version of my annotations :

```auto
    @Textuel
	@Transient
	@IndexedEmbedded(includePaths = {
			ClientPhysique_.UUID, ClientPhysique_.NOM, ClientPhysique_.PRENOM, ClientPhysique_.DATE_NE
	})
	@AssociationInverseSide(inversePath = @ObjectPath(@PropertyValue(propertyName = "conjoint")))
	@IndexingDependency(
			derivedFrom = {
					@ObjectPath({@PropertyValue(propertyName = "matrimoniauxMadame"), @PropertyValue(propertyName = "monsieur"), @PropertyValue(propertyName = "nom")}),
					@ObjectPath({@PropertyValue(propertyName = "matrimoniauxMadame"), @PropertyValue(propertyName = "madame"), @PropertyValue(propertyName = "nom")}),
					@ObjectPath({@PropertyValue(propertyName = "matrimoniauxMonsieur"), @PropertyValue(propertyName = "monsieur"), @PropertyValue(propertyName = "nom")}),
					@ObjectPath({@PropertyValue(propertyName = "matrimoniauxMonsieur"), @PropertyValue(propertyName = "madame"), @PropertyValue(propertyName = "nom")})
			}
	)
	public ClientPhysique getConjoint() {
		// compute conjoint
		return conjoint;
	}

```

I try to specify every property on the path on every associations used for the computing of conjoint but, it not working better

---

_[View the full topic](https://discourse.hibernate.org/t/hibernate-search-6-advanced-mapping/2996)._
