Use query_string for full-text search in parent-child tables in ElasticSearch

Hello,
we have found a strange behavior inside ElasticSearch querying.
We have two types which are connected together as parent (applicant) and child (attachment).

Mapping for parent table:

 {
 	"Applicant": {
 		"properties": {
 			"Name": {
 				"type": "string"
 			},
 			"Focus": {
 				"type": "string"
 			},
 			"KnowHowClassification": {
 				"type": "string"
 			}
 		}
 	}
 }

Mapping for child table:

{
	"Attachments_Applicant": {
		"_parent": {
			"type": "Applicant"
		},
		"properties": {
			"File": {
				"type": "attachment"
			}
		}
	}
}

We need to query all fields across both tables to find certain keywords and return parent document.
For this we are using following query:

{
  "from": 0,
  "size": 100,
  "query": {
    "bool": {
      "should": [
        {
          "has_child": {
            "type": "Attachments_Applicant",
            "query": {
              "bool": {
                "must": [
                  {
                    "query_string": {
                      "query": “{{search}}”
                    }
                  }
                ]
              }
            }
          }
        },
        {
          "query_string": {
            "query": “{{search}}”
          }
        }
      ]
    }
  }
}

If we search for “java css” (without quotes) we find documents that have either or both the terms.

If we search for “+java +css” (without quotes) we find only documents that have both those terms in one of the tables. If one of the terms is in the applicant table and another one in attachment table, then those documents are not returned.

Is there a way to query all fields parent-child tables with query_string which has required terms (+)?

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