I am currently getting started with Elasticsearch and I am trying to build a search query that looks for a keyword in different fields, dependent on the document type.
Example:
Index Name: index1
Document types:
- doc1 (_id, name, size, color, weight)
- doc2 (_id, name, duration, length, width, height)
Now I want to query index1
for documents of types doc1
and doc2
, but indoc1
I only want to search in columns name
, size
and weight
, whilst in doc2
I want to search in columns name
, length
and height
.
How can I achieve this in a single query?