R
R
Rag'n' Code Man2021-07-26 17:02:53
elasticsearch
Rag'n' Code Man, 2021-07-26 17:02:53

How to search across all indexes in ElasticSearch?

I have 2 indexes: students and groups
With data structure like this

{
    id,
    name,
    surname,
    midname,
    phone,
    parentPhone
} // ученик

{
    id,
    GROUP_NAME
} // группа


I need to implement autocomplete in CRM system (search everywhere).

What should a query look like to search all indexes and all fields at once?

That is, elastic should search by first name, last name, patronymic, phone number, parent phone number, and group name at the same time. In this case, it is necessary that the word does not need to be completed in full.

That is, to find all the Dmitrievs, simply write “Dmi” or “Dm”.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Cheremisin, 2021-07-26
@iDmitriyWinX

How did you try? And why a question of "average" complexity? Elastic seems to be looking for all the indices, separated by commas. GET /index1,index2/_search .....
Well, for several fields - simple_query string query - https://www.elastic.co/guide/en/elasticsearch/refe...
or query string query or all together in combination with bool query in different versions.
Here, however, the question of promapping should also be about tokenizers, but this is already a "complex" option, when the "simple" one does not help...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question