Skip to content

Zentity not honoring nesting #115

Description

@LydiaBartholomew

Environment

  • zentity version: 1.8.1
  • Elasticsearch version: 7.10.2

Describe the bug

Zentity does not appear to honor a nested index structure. I have an index definition with person data fields (names, addresses, phones, etc.). The addresses are nested in the index definition (e.g. Addresses.FullStreet, Addresses.City). The matcher in the model definition specifies that they are nested and the indices section uses dot notation to map to the index definition (e.g. Addresses.FullStreet). When I search a street address, city, state, and zip, any one of the street addresses will match against anyone of the city, state, and zips rather than grouping a street address with a particular city, state, and zip. I also can't seem to get my firstname, lastname, state resolver to match but I'm assuming I have a typo somewhere.

Expected behavior

I expected that each full address (street, city, state, zip) would be evaluated separately from other full addresses.

Steps to reproduce

  1. PUT index definition with nested addresses: {"settings":{"index":{"number_of_shards":1,"number_of_replicas":0,"analysis":{"filter":{"street_suffix_map":{"pattern":"(st)","type":"pattern_replace","replacement":"street"},"phonetic":{"type":"phonetic","encoder":"nysiis"},"punct_white":{"pattern":"\p{Punct}","type":"pattern_replace","replacement":" "},"remove_non_digits":{"pattern":"[^\\d]","type":"pattern_replace","replacement":""},"remove_punct":{"pattern":"[^a-zA-Z0-9]","type":"pattern_replace","replacement":""}},"analyzer":{"name_clean":{"filter":["icu_normalizer","icu_folding","punct_white"],"tokenizer":"standard"},"name_phonetic":{"filter":["icu_normalizer","icu_folding","punct_white","phonetic"],"tokenizer":"standard"},"street_clean":{"filter":["icu_normalizer","icu_folding","punct_white","trim"],"tokenizer":"keyword"}}}}},"mappings":{"properties":{"Names":{"type":"nested","properties":{"FirstName":{"type":"text","fields":{"clean":{"type":"text","analyzer":"name_clean"},"phonetic":{"type":"text","analyzer":"name_phonetic"}}},"MiddleName":{"type":"text","fields":{"clean":{"type":"text","analyzer":"name_clean"},"phonetic":{"type":"text","analyzer":"name_phonetic"}}},"LastName":{"type":"text","fields":{"clean":{"type":"text","analyzer":"name_clean"},"phonetic":{"type":"text","analyzer":"name_phonetic"}}}}},"Addresses":{"type":"nested","properties":{"FullStreet":{"type":"text","fields":{"clean":{"type":"text","analyzer":"street_clean"}}},"City":{"type":"text","fields":{"clean":{"type":"text","analyzer":"name_clean"}}},"State":{"type":"text","fields":{"clean":{"type":"keyword"}}},"Zip":{"type":"text"},"Zip4":{"type":"text"}}}}}}
  2. PUT model definition indicating addresses are nesting: {"attributes":{"name.first_name":{"type":"string","score":0.6125},"name.middle_name":{"type":"string","score":0.6125},"name.last_name":{"type":"string","score":0.65},"address.full_street":{"type":"string","score":0.75},"address.city":{"type":"string","score":0.55},"address.state":{"type":"string","score":0.5125},"address.zip":{"type":"string","score":0.75}},"resolvers":{"full_name":{"attributes":["name.first_name","name.last_name"]},"first_last_city":{"attributes":["name.first_name","name.last_name","address.city"]},"first_last_state":{"attributes":["name.first_name","name.last_name","address.state"]},"first_last_zip":{"attributes":["name.first_name","name.last_name","address.zip"]},"street_city":{"attributes":["address.full_street","address.city"]},"street_state":{"attributes":["address.full_street","address.state"]},"street_zip":{"attributes":["address.full_street","address.zip"]},"last_street":{"attributes":["name.last_name","address.full_street"]}},"matchers":{"simple_nested_name":{"clause":{"nested":{"path":"Names","query":{"match":{"{{ field }}":"{{ value }}"}}}},"quality":0.975},"fuzzy_nested_name":{"clause":{"nested":{"path":"Names","query":{"match":{"{{ field }}":{"query":"{{ value }}","fuzziness":"1"}}}}},"quality":0.95},"simple_nested_addresses":{"clause":{"nested":{"path":"Addresses","query":{"match":{"{{ field }}":"{{ value }}"}}}},"quality":0.95},"exact_nested_address":{"clause":{"nested":{"path":"Addresses","query":{"term":{"{{ field }}":"{{ value }}"}}}},"quality":1.0},"fuzzy_nested_address":{"clause":{"nested":{"path":"Addresses","query":{"match":{"{{ field }}":{"query":"{{ value }}","fuzziness":"1"}}}}},"quality":0.95}},"indices":{"person_list":{"fields":{"Names.FirstName.clean":{"attribute":"name.first_name","matcher":"fuzzy_nested_name","quality":0.975},"Names.FirstName.phonetic":{"attribute":"name.first_name","matcher":"simple_nested_name","quality":0.925},"Names.MiddleName.clean":{"attribute":"name.middle_name","matcher":"fuzzy_nested_name","quality":0.975},"Names.MiddleName.phonetic":{"attribute":"name.middle_name","matcher":"simple_nested_name","quality":0.925},"Names.LastName.clean":{"attribute":"name.last_name","matcher":"fuzzy_nested_name","quality":0.975},"Names.LastName.phonetic":{"attribute":"name.last_name","matcher":"simple_nested_name","quality":0.925},"Addresses.FullStreet.clean":{"attribute":"address.full_street","matcher":"simple_nested_addresses","quality":0.975},"Addresses.City.clean":{"attribute":"address.city","matcher":"simple_nested_addresses","quality":0.975},"Addresses.State.keyword":{"attribute":"address.state","matcher":"exact_nested_address"},"Addresses.Zip":{"attribute":"address.zip","matcher":"simple_nested_addresses","quality":0.975}}}}}
  3. Index data: {"index": {"_id": "1", "_index": "person_list"}}
    {"Names":[{"FirstName":"Jane","MiddleName":"D","LastName":"Smith"},"Addresses":[{"FullStreet":"123 Main St","City":"Barnstable","State":"MA","Zip":"02632","Zip4":""},{"FullStreet":"567 North St","City":"Arlington","State":"VA","Zip":"22201"}]}
    {"index": {"_id": "2", "_index": "person_watch_list"}}
  4. Search: POST _zentity/resolution/person_model?_score=true&pretty&_explanation=true&max_hops=0
    {
    "attributes": {
    "name.last_name": ["Smith"],
    "name.first_name": ["Jane"],
    "address.full_street":["567 North St"],
    "address.city":["Barnstable"],
    "address.state":["MA"],
    "address.zip":["02632"]
    }
    }

Additional context

The search above matches with the street_city and street_zip resolver. I would hope this would not match and would only match if I changed address.full_street to "123 Main St". Thank you in advance for your help!

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions