Filter by field for specific index on multi index query

I've got two indexes which i can search on but wan't to filter by a field on one index and not the other.

e.g.

Index1 Index2
content content
parent parent
... ...

They share some common mappings.

I want to search in content but if the match is also in index 2 then filter by the parent field in that index.

I thought I might have been able to use script in the filter but I don't think _index is accessible in _doc

[
  'script' => [
    'script' => [
      'source' => 'doc[\'_index\'] == \'index2\' ? (doc[\'parent\'] == 1) : true',
      'lang' => 'painless'
    ]
  ]
]

Is something like this possible?

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