简体   繁体   中英

what is simplest way to handle not in elasticsearch?

In last few months I have developed mix panel application in rails,That collecting data from mobile application,And based on mobile application I have two kind of index witch contain user profiles and user event,In user profile index I collect user profile data like name, email, phone number ... and in user events index I only collect some specific action that user done in mobile app like "app open", "sign up" and .... In my app I use elastic search as search engine.AS result of bushiness requirement I have to separate these two index to two different index and inserted in elastic search. Every things was fine till I found When mix panel admin login and want to search over elastic search data search result was wrong. As i explain before for every mobile users I have two indexes that contain profile and event ,I use profile id in profile indexes to search over data And I have to add profile id is unique in both profile and event indexes so with profile Id I could find user event, so every user must have profile and at least have one event indexes in my design that admin could found that user data, the problem is one profile have not event, let's me explain. suppose mobile application admin decide to generate profile for bushiness user so we have profile in our system that not have any event so when mix panel admin want to find profile that not have any event elastic return no data, In other word if admin want to find profile from event indexes elastic return no data because it's impossible event exist without profile.In my scenario I have at least two query to search over elastic search, and I know about nested query and parent-child query in elastic search but it's impossible as reason of time cost and query performance. so dose any one have any idea how could I handle my issues with min changes in query.I have to add i use bool query and term query as default query for my elastic search.

You can check _msearch query .

By using it you can a send single query to elasticsearch and get responses from both indices and merge them in the application. But elasticsearch will send multiple requests internally anyway. Here is an example:

GET _msearch
{ "index": "index1" }
{"query":{"term":{"field1":{"value":"some value 1"}}}}
{ "index": "index2" }
{"query":{"term":{"field2":{"value":"some value 2"}}}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM