Data type - array, flattened or nested?

We are indexing records that may have one or more full names and one or more full addresses.

We want to be able to search against those without getting cross matches so a simple JSON array or delimited concatenation will not suffice. Is that accurate? If we indexed the document below, a search for "88 Avenue" against the fullAddress field would match this document?

"sourceURN" : "H12345",
"fullAddress": ["88 High Street", "11 The Avenue"]

Based on documentation on "flattened" and "nested" it sounds like the flattened type should work as we do not care about the relationship between child properties.

"sourceURN" : "H12345",
"sourceName": "Database Name",
"addresses": {
      "fullAddress": ["88 High Street, Hatfield…", "11 The Avenue, Welwyn…"],
      "locationRef": ["urn1234", "urn4321"]
}
"aliases": {
      "fullName": ["Brian Arthur SMITH", "John Ringo BEATLE","William Roger JONES"],
      "aliasID": ["urn987","urn789"]
}

If a search was made against aliases.fullName for "Brian JONES" we would not want the example above included in the results. Brian and Jones appear in the array of full names but we only want a match where the searched terms appear in a single item in the array. We would want the following searches to include this record (doc) "Brian SMITH", "Arthur Smith" or even "Ringo John".

Similar for address, we wouldn't want a search for "88 Avenue" to include this result.

Although the locationRef and aliasID property values would relate to (some of) the fullName and fullAddress property values, we do not need to worry about their true key/value pair relationship when searching the Elastic index. We just need to be able to find a record based on one of those URNs so we may flag it for re-indexing. (This is based on our understanding that you cannot modify a nested object value, only replace/re-index the entire collection.)

We are trying to avoid using Nested data type because the documentation advises...

Nested documents and queries are typically expensive.

One more important question... can we apply synonyms against a property inside a flattened field, like aliases.fullName?

Thanks in advance of your kind response.

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