Search using result of previous search as parameter


(Khalil CHARFI) #1

Hi,

I need a help please, I have searched many topics and didn't find the answer.

I need to pass result of search as parameters like in SQL : SELECT * FROM Table Where Field_1 = (SELECT Field_1 FROM Table WHERE Field_2 = 'searched_data')

Here is my search in elasticsearch.

 GET _search
  {
  "query": {
    "query_string": {
    "default_field": "msgbody",
     "query": "searched_data"
   }
 },
 "_source": ["thread_name"],
 "size" : 1
}

I tried to pass in params but didn't find the right way:

 GET _search/template
 {
   "source" : {
    "query": { 
    "match_phrase" : { "{{my_field}}" : "{{my_value}}" }
     }
   },
 "params" : {
  "my_field" : "thread_name",
  "my_value" : "my_search_results"
  }
}

So my question is it possible to get result like SQL?

In case that's not possible, do you have any suggestion to get simular result?

Best Regards

Khalil CHARFI


(Khalil CHARFI) #2

Up please any response will help me.

Thank you.


(David Pilato) #3

Please read

Specifically the "be patient" part.


(David Pilato) #4

You can't do that automatically so you need to solve that on your side (client side).
You will end up doing multiple calls.


(Khalil CHARFI) #5

Thank you for your Help.

I know this is hard to answer every one.

I will be patient.

Best Regards

Khalil CHARFI


(system) closed #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.