More Like this query against a combination of nested/join fields and regular fields

I want to run a "More Like this" query against a combination of nested/join fields and regular (non-nested/join) fields. Is this possible? Against the following index mapping--

PUT /persons

{
	"mappings": {
		"person": {
			"properties": {
				"education": {
					"type": "nested",
					"properties": {
						"degree-name-en": {
							"type": "keyword"
						},
						"major-en": {
							"type": "text"
						},
						"school-name-en": {
							"type": "keyword"
						}
					}
				},
				"first-name": {
					"type": "keyword"
				},
				"last-name": {
					"type": "keyword"
				}
			}
		}
	}
}

I am trying to run this type of query against the index:

{
	"query": {
		"nested":{
			"path" : "education",
			"query" : {
				"more_like_this": {
					"fields": [
						"education.degree-name-en", "last-name"
					],
					"like": [
						{
							"_index": "persons",
							"_type": "person",
							"_id": "1"
						}
					],
					"min_term_freq": 1,
					"min_doc_freq": 1,
					"boost_terms" : 1,
					"max_query_terms": 12
				}
			}
		}
	}
}

However, the "More Like This" query is not considering the "last-name" field at all, which makes sense since we are making a nested query on the "education" path. So, how do I make a query on against the "education.degree-name-en" (nested) field and "last-name" (non-nested) field in my "More Like This" query?

I have added the following documents to the index:

PUT persons/person/1

    {
      "first-name" : "John",
      "last-name" :  "Smith",
      "education" : [
      	{
      		"degree-name-en" : "bachelors of science",
      		"school-name-en" : "stanford university"
      	}
      	]
    }

PUT persons/person/2

    {
      "first-name" : "Alice",
      "last-name" :  "Peter",
      "education" : [
      	{
      		"degree-name-en" : "bachelors of science",
      		"school-name-en" : "harvard university"
      	}
      	]
    }

PUT persons/person/3

{
  "first-name" : "Peter",
  "last-name" :  "Smith",
  "education" : [
  	{
  		"degree-name-en" : "masters of science",
  		"school-name-en" : "harvard university"
  	}
  	]
}

With my "More-Like-This" query above, I would like both the docs with _ids, 2 and 3, to both match. Also, would the same be possible with "join" fields and "has_child" queries? Thanks in advance.

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