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

**URL:** <https://discuss.elastic.co/t/more-like-this-query-against-a-combination-of-nested-join-fields-and-regular-fields/171171>\
**Category:** Elasticsearch\
**Created:** [March 6, 2019, 6:05pm UTC](https://discuss.elastic.co/t/more-like-this-query-against-a-combination-of-nested-join-fields-and-regular-fields/171171 "2019-03-06T18:05:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![advitya](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@advitya](https://discuss.elastic.co/u/advitya)\
**Post date:** [March 6, 2019, 6:05pm UTC](https://discuss.elastic.co/t/more-like-this-query-against-a-combination-of-nested-join-fields-and-regular-fields/171171/1 "2019-03-06T18:05:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 3, 2019, 6:05pm UTC](https://discuss.elastic.co/t/more-like-this-query-against-a-combination-of-nested-join-fields-and-regular-fields/171171/2 "2019-04-03T18:05:03Z")

</div>

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