Conditional query based on index/type


(Remy Gendron) #1

Hi all,

I have fields (same names) that are present on all document types. Doing a
polymorphic search on these fields is therefore not a problem.

But, I have fields that are present only on some document types.

Is it possible to do a single search query (a boolean query) targeted at
multiple document types, that includes a field query for a field not
present on all document types.

I would like it to be a kind of conditional query where that field_query
would not be applied against document types where that field is not
present/mapped.

Rémy

--


(Remy Gendron) #2

Just saw the Indices Query... I guess I probably could use this.

I'd need to check every sub-query within the boolean query and explode the
main query as an indices query with as many query variants as necessary.

--


(Remy Gendron) #3

Looking at the code, I see that there is only one query matched against a
list of indices and another nomatch/defautl query.

What I would need is to be able to specify a different query for each
indices in the multi-indices query...

--


(system) #4