Query a nested object

Hello all,

I have got the following document and am trying to query its ids.ema_id value :

{
"took": 5,
"timed_out": false,
"_shards": {
	"total": 5,
	"successful": 5,
	"skipped": 0,
	"failed": 0
},
"hits": {
	"total": 12,
	"max_score": 16.52765,
	"hits": [{
		"_index": "records",
		"_type": "records",
		"_id": "1699",
		"_score": 16.52765,
		"_source": {
			"id": 1699,
			"house_id": null,
			"ids": {
				"ema_id": "GOODMORN11"
			}
		}
	}]
}

}

How would that be possible using elasticsearch-php?

Tried several things like $this->record->search() ->nested('ids', function (SearchBuilder $builder) use ($searchTerm) { $builder->filter()->term('ids.ema_id', $searchTerm); })->size(config('results_per_category'))->get()->hits();

but no luck.

Any ideas would be highly appreciated!

Update Mappings are as follows:

	"records": {
		"mappings": {
			"records": {
				"properties": {
					"ids": {
						"type": "nested",
						"properties": {
							"ema_id": {
								"type": "text",
								"fields": {
									"keyword": {
										"type": "keyword",
										"ignore_above": 256
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

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