Reputation: 21
I need help to search in the different indexes of the same cluster with different fields. For example: If I have a cluster name demo in which I have 2 indexes menu_items and purchase_orders. Both indexes contain different columns to search. Index menu_items contains 'label' field and index purchase_orders contains 'id' and 'supplier_reference' field.
$params = [ 'index' => 'menu_items,purchase_orders', '_source' => 'label,id,supplier_reference', 'body' => [ 'query' => [ 'bool' => [ 'must' => [ 'multi_match' => [ 'query' => $keyword, 'type' => 'bool_prefix', 'fields' => ['label', 'id', 'supplier_reference'], ], ], ], ], ], ];
Now If I am searching for any term '3312' which is available in both indexes so this query working good and another term 'supplier' is not available in another index at that time I got an error. Can anyone help here? How can I achieve this? How can we find fields in two or more different indexes?
Upvotes: 0
Views: 675
Reputation: 21
I face an issue as described below and as a solution what I found here is, we need to do the proper mapping.
Related to mapping, Elasticsearch has the built in ability to detect the type of the fields of a document and generate a schema and apply it throughout the index. But this causes an error while two indexes have different data types for the same field. ex: if index1 has id field with long data type and index2 has id field with the string data type. At that time search operation gives an error for search related to the id field which I described in the question.
Upvotes: 0